Yii Framework Forum: Authenticate Every Page - Yii Framework Forum

Jump to content

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

Authenticate Every Page Rate Topic: -----

#1 User is offline   yii_king 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 110
  • Joined: 05-August 12

Posted 31 March 2013 - 11:55 AM

I've created an application in Yii where you can do a simple login. Once I am signed in, I am basically in as long as my session persist. However, I would like to do a status check on every page visit for a user to ensure that he still has permissions to access the site (e.g. if the user gets inactived then he should not stay logged in).

What is the best approach to authenticate the user on every page; is it on Controller level, Controller method level, View level or some other way? Ideally it would be the easiest if the check is included once per controller. Can you please advise how you have done this?
0

#2 User is offline   fonis 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 55
  • Joined: 22-March 12

Posted 31 March 2013 - 12:26 PM

I'm not sure, but i think there is a place in the config file that sets how long time a user is logged in since the last time he was active (and i think the default is one hour).

To authenticate the user i'm using something like this code in my controller actions:

if(!Yii::app()->User->checkAccess('postUpdate'))
		{
			throw new CHttpException(401);
		}


EDIT: You should check out this: http://www.yiiframew.../en/topics.auth
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