Default group for User [SOLVED]

Archived from the Xataface Users forum.

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


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.


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 — Thu Sep 02, 2010 10:20 am

Defaults work with ENUMs

Sorted. Thanks loads.


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 — 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.