Default group for User [SOLVED]

A place for users and developers of the Xataface to discuss and receive support.

Default group for User [SOLVED]

Postby cantlep » Thu Sep 02, 2010 9:53 am

Hi Steve,

Currently, my app authenticates using LDAP. If a user tries to log in (assuming they never have before) and they're a member of the correct AD group, then they can log in with their AD credentials. This is cool..but...how can I make the default role to be something other than ADMIN (which it seems to default to). I've created a new role called WORKOUTUSER so I'd like that to be the default.

Thanks as always

Paul
Last edited by cantlep on Thu Sep 02, 2010 10:36 am, edited 3 times in total.
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am

Re: Default group for User

Postby shannah » Thu Sep 02, 2010 10:11 am

Assuming your just storing the role in a column of the users table, you could just make that role the default value for that column in the mysql table definition.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Default group for User

Postby cantlep » Thu Sep 02, 2010 10:17 am

I'm currently using an ENUM value that contains a few different perms. i.e
Code: Select all
'ADMIN','READ ONLY','WORKOUTUSER','BLAH'


I guess that's not the best way to do it then
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am

Re: Default group for User

Postby cantlep » Thu Sep 02, 2010 10:20 am

Defaults work with ENUMs :-)

Sorted. Thanks loads.
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am

Re: Default group for User

Postby cantlep » Thu Sep 02, 2010 10:32 am

Hi Steve,

hmm, I lied. Whilst the default is recognised (in the DB), it's not being honoured. Also, found this snippet
If an ENUM column is declared to permit NULL, the NULL value is a legal value for the column, and the default value is NULL. If an ENUM column is declared NOT NULL, its default value is the first element of the list of permitted values.

In my case, the WORKOUT role *is* the first in the list so it should be picking that up anyway (from what I can tell)..but still isn't.. It still uses ADMIN

Any ideas?
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am

Re: Default group for User

Postby cantlep » Thu Sep 02, 2010 10:36 am

Sorted!

My bad. The ldap config had a default role specified in there: (which I've now changed).
Code: Select all
$sql = "insert into ".$auth->conf['users_table']." (".$auth->conf['username_column'].",ROLE,UserEmailAddress) value ('".$creds['UserName']."','WORKOUTUSER','".$entries[$i]['mail'][0]."')";


Sorry.

Cheers.
cantlep
 
Posts: 172
Joined: Fri Mar 05, 2010 2:14 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 37 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved