Forums | Mahara Themes
General discussion
/
Get user auth method?
15 June 2010, 8:18
Within a template, is it possible to tell what method of authentication a user has used to enter into Mahara? I'd like to tell if a user has entered via the login page or MNet.
I was hoping for something like {$user|auth}, like Moodle's $user->auth. Maybe Im just too use to developing for Moodle.
15 June 2010, 8:37
OK, worked it out, so I'll answer my own question (please correct me if I'm wrong)...
It seems you can pull data from the user table using $USER->get().
So $USER->get('authinstance') returns the id of the auth plugin used when the user account was set up.
Well regardless of exactly what's going on in the background, that tells me what auth plugin was used. Although if someone could elaborate further I'd be eternally grateful :)
16 June 2010, 20:37
Those authinstance ids are just references to the auth_instance table in the database, so you have to do more work to find out the actual auth method.
There is some code in the online users sideblock (onlineusers_sideblock function in lib/mahara.php) that you should find useful - it displays the name of the mnet host beside the name of every mnet user.