# Forums | Mahara Community

## Developers / pktr auth plugin

Deleted user
Posts: 1

13 April 2011, 4:03 PM

Hello there!

We have a system written in php and we wish to integrate with mahara. We have succesfully wrote an auth plugin so users can login into mahara with they user names they have in our system and so on. We have 3 kind of users in our system(site admin, institutional admin, simple user) and now any of them can log in and simple users are just there in the institution and our site admin can log in with his user account into mahara too.

This is all good, but we have a little problem with the institutional admins... After studying your database one can easily found out that there is a field in the usr_institution table called admin and that's the responsible for the users 'adminness' in that institution.  We have also found out, that the so called auth->login() function runs after the users auto creation in mahara, so we decided to put a little code there that changes the admin column for the user in the database.

This runs nearly as expected, but there is a little problem. The problem is that if we do it this way, and the user logs in for the first time he (seemingly) does not get the admin rights for the institude, he only realises that change if he logs out and then logs in. I think the cause is that the changes take place after some reading from that table and the site remains in the state that was before the database change. We are trying to get around this because it's a little usability problem with our system this way...

This is the code in the overridden login():

global $strUserName ; global$pepruser ;
global $USER ; if(!$pepruser->bDiak){
// Bejelentkezett felhasználó userneve
// Usernévhez tartozó rekord lekérdezése a userId miatt
$rUsrRecord = get_record('usr', 'username',$strUserName) ;
$nUsrId =$rUsrRecord->id;
// Maharás user pktr-es kezelési köre tiszk-e a pktrben
$bTiszke =$pepruser->intezmeny->tiszke ;
// Aktuális intézmény lekérdezése
$strInstitutionName =$this->institution ;