Re: [Phplib-users] User Self-Registration
Brought to you by:
nhruby,
richardarcher
From: Nathaniel P. <np...@te...> - 2003-07-22 16:46:22
|
----- Original Message ----- From: "Virilo Tejedor" <vi...@su...> To: <php...@li...> Sent: Monday, July 21, 2003 2:41 PM Subject: [Phplib-users] User Self-Registration > Some years ago Daniel Cunningham wrote: > > (this is an extract from the original message: > http://marc.theaimsgroup.com/?l=phplib&m=94101973230198 ) > > > ... > > > > > I'd like for my users to be able to push a button and go to another > > form and setup a username/password for their account. In > > other words, self-registration, using a form, and overrides of the > > auth_registerform() and auth_doregister() methods. > > > There are great examples of the former ( auth_loginform() and > > auth_validatelogin() ) but not the latter ( auth_registerform() > > and auth_doregister() ). There are also examples for an admin > > type user to add user records, but that's not what we want. > > > We just want a form with straight-forward self-service non-privileged > > "enter your own test username and password" , and once we've > > validated the username against other entries in the auth_users table, > > we would setup a username/password and priv="user" entry. > > > And also hopefully synchronize this auth_user entry with the > > existing session ID so that the user is not forced to re-login via > > the auth_login() and auth_validatelogin() methods. > > Im interested in the same. Finally he ofers us his own implementation. Has > anybody a better solution? anymore about it? > > > Thanks in advance. Sorry for my english, my spanish is better. > > Virilo Tejedor. Email: vi...@su... > If all you are doing is wanting to use the same form for both user login and user registration, it should be fairly straightforward. In your Auth subclass, you would set the $mode to 'reg', setup auth_registerform() to display the registration form (if this is the same as the normal login form, you could probably just have it in turn call auth_loginform() to display it), then you would set up auth_doregister() to first check to see if the login name and password provided are valid, and if they aren't, then go ahead and register the user in the system. The code might look something like this. ExampleAuth extends Auth { //...other settings variables go here var $mode = 'reg'; function auth_registerform() { //code to display the registration form goes here; usually you can just copy //and modify the code for auth_loginform() to suit your purposes. } function auth_doregister() //validate the login... you can probably use the existing //auth_validatelogin to do this if (!$uid = $this->auth_validatelogin()) { //A valid uid wasn't returned, so go ahead and register the user. //...registration code goes here; be sure to set the uid and perms for the new //user ... $uid = (something); $this->auth['perm'] = 'user'; } return $uid; //return the uid to PHPlib so that it recognizes the user as valid. } function auth_validatelogin() { //Code to login a user goes here return $uid; } ... } I have also found in working with the Auth class that this flow chart has helped me immensely: http://www.drostan.org/Application/webdev/uod/auth_phplib.php P.D. Si necesita algu'n explanacio'n en espan~ol, puedo intentar clarificar lo que dije. Quizas tendre' que buscar mi diccionario. :) _________________________________ Nathaniel Price <np...@te...> Webmaster |