SHARE
TWEET

Untitled

a guest Apr 17th, 2019 148 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     <cffunction name="Login" access="remote" httpMethod="POST" restpath="login" returntype="struct">
  2.         <cfargument name="email" type="string" required="true" restargsource="form">
  3.         <cfargument name="password" type="string" required="true" restargsource="form">
  4.  
  5.         <cfheader name="Access-Control-Allow-Origin" value="*">
  6.         <cfheader name="Access-Control-Allow-Header" value="poopoo">
  7.         <cfheader name="Content-Type" value="application/json; charset=utf-8">
  8.         <cfheader name="pooopoo" value="poopoo">
  9.  
  10.         <cfset epoch = round(now().getTime() / 1000) />
  11.  
  12.         <cfquery name="checkUser" datasource="#Application.PrimaryDatasource#">
  13.             SELECT *
  14.             FROM Internet_Users
  15.             WHERE
  16.                 User_Email = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.email#" />
  17.                 AND User_Pass =  <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.password#" />
  18.         </cfquery>
  19.  
  20.         <cfif checkUser.recordCount gt 0>
  21.             <cfset payload.success = true />
  22.         <cfelse>
  23.             <cfset abortRequest(
  24.                 401,
  25.                 "Unauthorized",
  26.                 "Username or password is incorrect",
  27.                 401
  28.             ) />
  29.         </cfif>
  30.  
  31.  
  32.         <cfset jwt = new com.system.jwt(application.JWTSecret)>
  33.         <cfset tokenPayload = {
  34.             'iat': epoch,
  35.             'exp': epoch + (30 * 60),
  36.             'email': arguments.email,
  37.             'password': arguments.password
  38.         } />
  39.  
  40.         <cfset token = jwt.encode(tokenPayload) />
  41.  
  42.         <cfset payload.data = token />
  43.         <cfreturn payload />
  44.     </cffunction>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top