Yii Framework Forum: assigning a default rol to new users - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

assigning a default rol to new users some api? Rate Topic: -----

#1 User is offline   Juan Pablo Sala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 65
  • Joined: 16-June 09

Posted 07 October 2010 - 08:27 AM

Hi Spyros, THANKS a lot for your work, you save as a lot of time!
Is there a way, maybe without touching the tables by sql, to assign a roll to a user? in this case what I want is to assign a default roll to new users.

Thanks

Juan
0

#2 User is offline   Juan Pablo Sala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 65
  • Joined: 16-June 09

Posted 07 October 2010 - 08:52 AM

Hi, I finally did this, do you think is the right way?

protected function afterSave()
{
$auth = Yii::app()->authManager;
$auth->assign('userRol', $this->username);
$auth->save();

parent::afterSave();
}

Thanks
0

#3 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 07 October 2010 - 11:25 PM

I think this should work
0

#4 User is offline   Juan Pablo Sala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 65
  • Joined: 16-June 09

Posted 10 October 2010 - 02:44 PM

Thanks!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users