Page 1 of 1

Registration Form

PostPosted: Fri Mar 20, 2009 3:14 am
by Martin Pruss
hi Steve
Currently I am trying to get my registration form running...
I followed your tutorial (http://xataface.com/documentation/how-t ... gistration)
Step by step but maybe I am missing something.
I am using the latest version of Xataface.

conf.ini has
allow_register = 1

A register Link appears on the login screen
but, when clicked, only the before_registration_form
is shown.
when i look at the source code of the generated page I find a
form with hidden input fields:
Code: Select all
<form>
<form accept-charset="ISO-8859-1" action="http://www.trainingskalender.de/streak/index.php" method="post" name="new_streak_users_record_form" id="new_streak_users_record_form">
<input name="_qf__new_streak_users_record_form" type="hidden" value="" />
<input name="-action" type="hidden" value="register" />
<input name="__keys__[UserID]" type="hidden" value="" />
<input name="-new" type="hidden" value="1" />

etc....


In the Tutorial i found the following:
Please note that the isAdmin() and getUsername() functions
were defined elsewhere and are convience functions
wrapping calls to the Dataface_AuthenticationTool object.

Does this mean that I have to define them somewhere?



cheers
martin

PostPosted: Fri Mar 20, 2009 9:48 am
by shannah
You need to allow the "new" permission on the users table for the public in order to allow for public registration.

PostPosted: Mon Mar 23, 2009 8:35 am
by Martin Pruss
Hi Steve thanks for your support..
Well..your reply helped...but also made some new problems appear
first:
after the register form was up and running, the filters stopped working and the main table was visible for all ...i think i can solve that on my own by diving deeper in the permissions documentation.

second:
i could'nt make the role field in the users table disapear via the
fields.ini (but i have to, otherwise new users can make themselves admins)
when i add:
[role]
visibility:list = hidden
widget:label = "Test"
widget:description = ""
widget:type = hidden
[email]
visibility:list = hidden
widget:label = "Rechte"
widget:description = ""
widget:type = hidden

only the email field disapears, but it writes Test as a field label

do you have an idea?


Martin

PostPosted: Mon Mar 23, 2009 11:56 am
by shannah
This is where permissions come in. You need to define more refined permissions for the 'role' field.

e.g.

Code: Select all
function role__permissions(&$record){
    if ( !isAdmin() ) return array('edit'=>0, 'new'=>0);
    return null;
}



Note that this assumes that you have created a function to tell whether the current user is an admin.

PostPosted: Tue Mar 24, 2009 1:13 am
by Martin Pruss
Hi Steve..
The Role field still refuses to apply the changes
even when I use the function without conditions e.g.:

Code: Select all
function Role__permissions(&$record){
     return array('edit'=>0, 'new'=>0);
    return null;
}


the role field has a capital R in my case...

??
cheers
martin

PostPosted: Mon Mar 30, 2009 4:54 am
by Martin Pruss
finally I disabled the display of the role selct box
by css
Code: Select all
#Role{display: none;}


nevertheless I am wondering what is so special about the Role field , that I can't hide it via fields.ini
cheers
Martin

PostPosted: Thu Apr 02, 2009 9:08 am
by fongchun
You should be able to hide it in the fields.ini I believe. You mentioned that the role is a capital 'R" in your database. It might be case sensitive, so make sure it is 'Role' in the fields.ini file too.

registration almost complete and working ...but..

PostPosted: Tue Apr 14, 2009 1:38 am
by Martin Pruss
Hi fongchun..
nope..capital "R" was not the mistake... thanks for the clue

Hi Steve
The registration process works. That means an email is sent to the registrant, with the activation link. and when the activation link is klicked the user can login.

But after saving the register form i get a 404.error:
Not Found

The requested URL /streak/index.php&--msg=Thank+you.+An+email+has+been+sent+to+testuser@gmx.de+with+instructions+on+how+to+complete+the+registration+process. was not found on this server.

and after klicking the activation email I get another one:
Not Found

The requested URL /streak/index.php&--msg=Registration+complete.++You+are+now+logged+in. was not found on this server.

Do you have any ideas what could have been gone wrong?

PostPosted: Thu Apr 16, 2009 2:17 am
by Martin Pruss
Do i have to redirect to a "thanks for registering" or "activation successful" template html?

thanks
martin

PostPosted: Thu Apr 16, 2009 8:27 am
by shannah
This may be a small bug in Xataface. You should be able to correct this by inserting the following just before line 172 of actions/register.php:
Line 172 is currently:
Code: Select all
header('Location: '.$url.'&--msg='.urlencode($msg));

Insert the following just before this:
Code: Select all
if ( strpos($url, '?') === false ) $url .= '?';


-Steve

PostPosted: Thu Apr 16, 2009 2:21 pm
by Martin Pruss
Hi Steve..
Thanks a lot..
this snippet solved my (coding) problems
thousands can register now :wink: ... (as soon as I am done with internationalisation)
cheers
martin

PostPosted: Fri Oct 23, 2009 11:44 am
by yakotey
shannah wrote:You need to allow the "new" permission on the users table for the public in order to allow for public registration.


Hi Steeve.

How do we achieve that?

My registration form still does not show up.

Thanx.

PostPosted: Mon Oct 26, 2009 2:47 pm
by shannah
In the users table delegate class you might have something like:

Code: Select all
function getPermissions(&$record){
    $query =& Dataface_Application::getInstance()->getQuery();
    $user = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
    if ( !$user  ){
        return array('new'=>1);
    }
    return null;
}



You should be careful to NOT allow access to fields that only an administrator should have access to. For example if you have a field called role that stores the user's role, you would add permissions for that field:

Code: Select all
function role__permissions(&$record){
    if ( !isAdmin() ) return Dataface_PermissionsTool::NO_ACCESS();
    return null;
}


This assumes that you have defined a function somewhere called isAdmin() that tells you whether the current user is an administrator.

-Steve