Yii Framework Forum: Userlevel access - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Userlevel access Rate Topic: -----

#1 User is offline   aventro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 02-October 11

Posted 03 October 2011 - 01:40 AM

Greetings from Sweden.

I was recently introduced to Yii and I was amazed. All the generated code is amazing. I've been testing around a bit.

I've been creating a crud for "Users" model which contain username, password, salt and userlevel. I want to just give all with > userlevel than like 2 to have access to certain things.

If I understood correctly it is accessRules() method that control the access. How do I grab the userlevel and then compare to the current user logged in (or something like that) Do I only need to modify accessRules() in order to get this to working?

Thanks.
0

#2 User is offline   binkabir 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 194
  • Joined: 25-July 10
  • Location:Abuja,Nigeria

Posted 03 October 2011 - 02:04 AM

hello, you can use the RBAC(a bit complex but more robust) or learn more on accessRules()(this is more easier to implement).
alternatively you can have a helper class for lookup and access control.
0

#3 User is offline   aventro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 02-October 11

Posted 03 October 2011 - 02:10 AM

View Postbinkabir, on 03 October 2011 - 02:04 AM, said:

hello, you can use the RBAC(a bit complex but more robust) or learn more on accessRules()(this is more easier to implement).
alternatively you can have a helper class for lookup and access control.


Hello and thanks for your reply.
I will check it out! What is RBAC?
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,358
  • Joined: 12-October 09
  • Location:Croatia

Posted 03 October 2011 - 02:16 AM

Hi and welcome to the Yii forum

When posting to the forum, please pay attention to post in the proper section...

you made this post in the Yii 1.0.x section... as you are new to Yii and this version is deprecated I doubt you will start with this version :D

For RBAC check this documentation - http://www.yiiframew...-access-control
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   aventro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 02-October 11

Posted 03 October 2011 - 02:35 AM

View Postmdomba, on 03 October 2011 - 02:16 AM, said:

Hi and welcome to the Yii forum

When posting to the forum, please pay attention to post in the proper section...

you made this post in the Yii 1.0.x section... as you are new to Yii and this version is deprecated I doubt you will start with this version :D

For RBAC check this documentation - http://www.yiiframew...-access-control


RBAC seem very cool. But I'm not really sure what I need to store in the database in order to keep track of what user role the logged in user have. Are there any more specific article about this?

Thanks! And sorry for posting in the wrong section, early in the morning, developing :)
0

#6 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 513
  • Joined: 08-August 09

Posted 03 October 2011 - 03:23 AM

This wiki article seems will be usefull for you:
WIKI-RBAC
0

#7 User is offline   aventro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 02-October 11

Posted 03 October 2011 - 12:00 PM

Thank you, I guess I need to look on "CDbAuthManager" library to get Database user authentication, well I'll look over it later!
0

#8 User is offline   aventro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 02-October 11

Posted 04 October 2011 - 04:09 AM

View Postaventro, on 03 October 2011 - 12:00 PM, said:

Thank you, I guess I need to look on "CDbAuthManager" library to get Database user authentication, well I'll look over it later!


How do I call the No Authorization If the if-statement

if(Yii::app()->user->checkAccess('createUser')) {

fails?

Thanks
0

#9 User is offline   aventro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 02-October 11

Posted 05 October 2011 - 07:50 AM

Bump!
0

#10 User is offline   aventro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 02-October 11

Posted 07 October 2011 - 11:32 AM

Still need help :)
0

#11 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,358
  • Joined: 12-October 09
  • Location:Croatia

Posted 08 October 2011 - 02:26 AM

can you explain better your question... what you mean with "no authorization"

if the check fails you can throw an exception... or display a nice message..
Find more about me.... btw. Do you know your WAN IP?
0

#12 User is offline   aventro 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 02-October 11

Posted 12 November 2011 - 04:34 PM

How do I display a nice message?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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