Yii Framework Forum: Creating Rule To Checkaccess - Yii Framework Forum

Jump to content

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

Creating Rule To Checkaccess Rate Topic: -----

#1 User is offline   prat 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 124
  • Joined: 13-September 13

Posted 21 September 2013 - 01:13 AM

For changing password I have an old_password field which is required only in case of normal user but it is not required if user is admin. So how can I create a rule to check this.
0

#2 User is offline   Fabrizio Caldarelli 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 285
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 21 September 2013 - 01:34 AM

You should never save plain text password. You can only c'hange password but never read.
0

#3 User is offline   prat 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 124
  • Joined: 13-September 13

Posted 21 September 2013 - 02:14 AM

View PostFabrizio Caldarelli, on 21 September 2013 - 01:34 AM, said:

You should never save plain text password. You can only c'hange password but never read.


I think you have not understood my question. I have never mentioned that I am saving plain text password. I am saying that while updating password only normal user will be needing old password before updating new password while admin will not be needing old password for updating new password of any user.
0

#4 User is offline   Ankit Modi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 883
  • Joined: 19-February 13
  • Location:India

Posted 21 September 2013 - 02:29 AM

View Postprat, on 21 September 2013 - 01:13 AM, said:

For changing password I have an old_password field which is required only in case of normal user but it is not required if user is admin. So how can I create a rule to check this.



try this
 array('password_repeat', 'compare', 'compareAttribute' => 'password', 'on' => 'normal user'),

Thanks,
Ankit Modi
Skype : amodi06
0

#5 User is offline   nineinchnick 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 622
  • Joined: 12-September 11
  • Location:Bialystok, Poland

Posted 21 September 2013 - 03:21 AM

What Maggie Q wanted to say but didn't:

Use scenarios. In the action, check if user is an admin (using checkRules) and then switch model scenario based on that. In admin scenario the old password field will not be required and won't be validated. In others it will be.
Don't be a dick.
0

#6 User is offline   prat 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 124
  • Joined: 13-September 13

Posted 21 September 2013 - 03:32 AM

thanks for your suggestions
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