NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Johan van Zyl on November 11, 2014, 01:28:38 PM
-
Hi
A. LoginForm
in ValidateUpdate 2 End
After the User has been validated - i.e. legally logged in, depending what type of User, I would like to call a form populated with THAT users details to be edited by the User himself. How do I call that form inside code and how do I ensure that the form is populated with that users details?
The login and password is validated against the People table which also contains all other details of the logged-in user. Therefore I will have the peopleguid in a Session Value, say called peopleguid.
B. After user is done editing, upon leaving THAT form User must be logged out? How?
-
>> How do I call that form inside code
You can set the "URL on Save" to be the form.
>> how do I ensure that the form is populated with that users details
The easiest way is to set the settings on the Form, on the Advanced tab, to "fetch" the record. Usually sing some SessionValue (set in the Login) so it knows which record to load.
If this isn't clear join us on the webinar this week and we can step through it.
>> After user is done editing, upon leaving THAT form User must be logged out?
In form, PostUpdate routine
p_web.SetSessionLoggedIn(0)
cheers
Bruce
-
Thx Bruce,
I have two types of people who will log in.
Normals Users that would probably only ever be staff members of medxinfo and those who are in the People table.
When logging in the code will use the loc:login to distinguish who is logging in
if len(clip(loc:login)) = 10 and sub(loc:login,1,1) = 0 !probably a cell number
clear(people)
peo:cellno = clip(loc:login)
if Access:people.TryFetch(peo:cellno_ukey)
...
if a User logs in then after login the LoginForm can call IndexPage or whatever BUT if logging in with cellno then the PeopleNetWebForm must be called populated with that persons details. Upon Saving must be logged out, before they can cause any damage.,
I guess the question is: can there be a choice of URL on Save depending on what type of user logged in.
,,,
-
Try this Johan, this is how I am testing for three levels of user
Admin and Suppliers are in one table
Students are in another table
My login will take the user to one of two pages
The key is the p_web.Script( p_web.WindowOpen( SomePage ))
and some page can be 'blah.htm' where you want a static page to go to
or it can be 'subdomain.yoururl.com'
-------------------------------------------------------------
access:student.Open()
access:supplier.Open()
access:student.UseFile()
access:supplier.UseFile()
Loc:Login = p_web.Gsv('Loc:Login')
Loc:Password = p_web.Gsv('Loc:Password')
Stu:WebUserName =Loc:Login
Stu:WebPassword = Loc:Password
Sup:WebUserName =Loc:Login
Sup:WebPassword = Loc:Password
if Access:Supplier.Fetch(Sup:Login_K) = 0 ! Login = Stu:WebUserName, Stu:WebPassword
if Sup:LoginLevel=0; Sup:LoginLevel=5;.
p_web.SetSessionLevel(Sup:LoginLevel) !!<----- 5
p_web.ssv( 'LoginLevel', Sup:LoginLevel)
if Sup:LoginLevel=5
p_web.ssv( 'IndexTitle', 'Welcome Supplier ' & clip(Sup:Firstname) & ', '& Sup:LastName)
p_web.ssv( 'LoggedInAs', 'Supplier ' & clip(Sup:Firstname) & ', '& Sup:LastName)
ELSE
p_web.ssv( 'IndexTitle', 'Welcome Admin ' & clip(Sup:Firstname) & ', '& Sup:LastName)
p_web.ssv( 'LoggedInAs', 'Admin ' & clip(Sup:Firstname) & ', '& Sup:LastName)
END
p_web.ValidateLogin()
p_web.SetSessionValue('hash',0)
p_web.SetSessionLoggedIn(1)
if Sup:WebTheme~=''; p_web.ChangeTheme( Sup:WebTheme);.
p_web.Script( p_web.WindowOpen( SomePage )) !!<<<<<< Read this Johan
elsif Access:student.Fetch(Stu:Login_K) =0
loc:invalid = 'Loc:Login'
p_web.SetValue('retry',p_web.site.LoginPage)
p_web.DeleteCookie('loc__login')
p_web.DeleteCookie('loc__password')
p_web.SetSessionLevel(1)
p_web.ssv( 'LoginLevel',1)
p_web.ssv( 'IndexTitle', 'Welcome Student ' & clip(Stu:Firstname) & ', '& Stu:LastName)
p_web.ssv( 'LoggedInAs', 'Student ' & clip(Stu:Firstname) & ', '& Stu:LastName)
p_web.ValidateLogin()
p_web.Ssv('hash',0)
p_web.Script( p_web.WindowOpen( SomeOtherPage )) !!<<<<<< Read this Johan
p_web.SetSessionLoggedIn(1)
if Stu:WebTheme~=''; p_web.ChangeTheme( Stu:WebTheme);.
else
loc:Alert = 'Login Failed - Try Again.'
loc:invalid = 'Loc:Login'
p_web.SetSessionLevel(0) ! set the session level, and any other session variables based on the logged in user.
p_web.SetSessionValue('hash',0) ! clear the hash, so this login can't get "replayed".
p_web.ssv( 'LoggedInAs', 'Failed')
p_web.SetSessionLoggedIn(false)
End
access:student.Close()
access:supplier.Close()
-
Thx!
This looks like what I was looking for!
Later:
Wow - that works well!
So far I have only used this line of yours
p_web.Script( p_web.WindowOpen( SomePage )) !!<<<<<< Read this Johan
should be
p_web.Script( p_web.WindowOpen( 'SomePage' ))
off course<g>
THX!