-
-
Save petrichor8/1cbc7669440fc662cee7f40e96ed6cd5 to your computer and use it in GitHub Desktop.
custom returnLoginCheck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfif variables.$.event('expired') eq true> | |
<div class="alert alert-danger">#variables.$.rbKey('user.forgotexpired')#</div> | |
</cfif> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user.forgotexpired=The temporary login link that you requested has expired. Please request a new link. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//these go inside of a _tagFunction.cfm file | |
<cffunction name="returnLoginCheckCustom" output="false"> | |
<cfargument name="$"> | |
<cfset var rs=""> | |
<cfif not arguments.$.currentUser().isLoggedIn() and len(arguments.$.event('returnID')) and len(arguments.$.event('returnUserID'))> | |
<cfquery name="rs" datasource="#variables.configBean.getReadOnlyDatasource()#" username="#variables.configBean.getReadOnlyDbUsername()#" password="#variables.configBean.getReadOnlyDbPassword()#"> | |
select created from tredirects | |
where redirectID=<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.$.event('returnID')#" > | |
</cfquery> | |
<cfif rs.recordcount and rs.created gte dateAdd("d",-2,now())> | |
<cfset loginByUserID($.event('returnUserID'),arguments.$.event('siteID'))> | |
<cfset structDelete(session,"siteArray")> | |
<cfelse> | |
<cflocation url="?display=login&expired=true##reminder" addtoken="false"> | |
</cfif> | |
</cfif> | |
</cffunction> | |
OR | |
<cffunction name="returnLoginCheckCustom" output="false"> | |
<cfargument name="$"> | |
<cfargument name="minutesGoodFor" required="false" default="30" > | |
<cfset var rs=""> | |
<cfif not arguments.$.currentUser().isLoggedIn() and len(arguments.$.event('returnID')) and len(arguments.$.event('returnUserID'))> | |
<cfset var redirect=getBean('userRedirect').loadBy(redirectid=arguments.$.event('returnID'))> | |
<cfif redirect.exists() | |
and redirect.getCreated() gte dateAdd("n",-arguments.minutesGoodFor,now()) | |
and $.event('returnUserID') eq redirect.getUserID()> | |
<cfset var user=redirect.getUser()> | |
<cfif user.exists()> | |
<cfset user.login()> | |
</cfif> | |
<cfset structDelete(session,"siteArray")> | |
<cfelse> | |
<cflocation url="/forgot-login/?display=login&expired=true&showmore=forgotlogin" addtoken="false" /> | |
</cfif> | |
</cfif> | |
</cffunction> | |
//override login check method to enableto only be used for 30 minutes | |
$.getBean("userUtility").injectMethod( "returnLoginCheck", returnLoginCheckcustom ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment