I am trying to set up facebook alternative login. What I need to happen is when someone logins using facebook, it looks to see if that user email address is in my system. If it is not there, then it needs to insert a row into four different tables and set the email address into the appropriate field. If that email address is in the system, then it just filter the appropriate fields based on that users session id. Below is the code I have in the after login event for alternative login. Can someone help me with the code?
save_to_file("Succeeded: "+convert_type(e.loginSucceeded,"C")+" User: "+e.userId,"C:\loginevent.txt")
if e.loginSucceeded
dim CurrentUserName as c
CurrentUserName = e.userid
if CurrentUserName = ""
Dim cn as sql::connection
dim sqlCommand as c
flag = cn.open("::name::databasename")
flag = cn.execute(insert into tablename (emailfield) values (:e.userid))
flag = cn.execute(insert into tablename)
flag = cn.execute(insert into tablename)
flag = cn.execute(insert into tablename)
end if
if CurrentUserName <> ""
dim args as sql::Arguments
args.set("emailfield",CurrentUserName)
session.pvvid = sql_lookup("::name::databasename", "tablename", "emailfield = :emailfield","pvvid",args)
if session.pvvid > 0
args.set("PVVID", session.pvvid)
session.emailfield = sql_lookup("::name::databasename", "tablename", "pvvid = :pvvid", "pvvid",args)
end if
end if
end if
e.url = page after login
'To capture Last Login date and time
'0: Initialize connections
dim globalcn as sql::connection
flag = globalcn.open("::name::database name")
'1: Log entry into system
dim sql as c
dim args as sql::arguments
args.add("CurrentUserName",a5ws_getcurrentuser()) 'Gets logged in user
flag = globalcn.execute("UPDATE tablename SET LAST_LOGIN = getdate() where tablename = :CurrentUserName",args)
flag = globalcn.Execute(sql, args)
'x: Clean u
globalcn.FreeResult()
globalcn.Close()
delete globalcn
end function
save_to_file("Succeeded: "+convert_type(e.loginSucceeded,"C")+" User: "+e.userId,"C:\loginevent.txt")
if e.loginSucceeded
dim CurrentUserName as c
CurrentUserName = e.userid
if CurrentUserName = ""
Dim cn as sql::connection
dim sqlCommand as c
flag = cn.open("::name::databasename")
flag = cn.execute(insert into tablename (emailfield) values (:e.userid))
flag = cn.execute(insert into tablename)
flag = cn.execute(insert into tablename)
flag = cn.execute(insert into tablename)
end if
if CurrentUserName <> ""
dim args as sql::Arguments
args.set("emailfield",CurrentUserName)
session.pvvid = sql_lookup("::name::databasename", "tablename", "emailfield = :emailfield","pvvid",args)
if session.pvvid > 0
args.set("PVVID", session.pvvid)
session.emailfield = sql_lookup("::name::databasename", "tablename", "pvvid = :pvvid", "pvvid",args)
end if
end if
end if
e.url = page after login
'To capture Last Login date and time
'0: Initialize connections
dim globalcn as sql::connection
flag = globalcn.open("::name::database name")
'1: Log entry into system
dim sql as c
dim args as sql::arguments
args.add("CurrentUserName",a5ws_getcurrentuser()) 'Gets logged in user
flag = globalcn.execute("UPDATE tablename SET LAST_LOGIN = getdate() where tablename = :CurrentUserName",args)
flag = globalcn.Execute(sql, args)
'x: Clean u
globalcn.FreeResult()
globalcn.Close()
delete globalcn
end function
Comment