开发者

overwriting isAuthenticated() in symfony

i'm doing the Practical symfony with Doctrine - Jobeet Job Website just trying to understand how backend works, i'm trying to overwrite the isAuthenticated() function in frontend and backend, what i did is simple, in my apps\frontend\lib\myUser.class.php file, i did this public

function isAuthenticated()
{
    return (bool)($this->authenticated && $this->getAttribute('is_customer', false, 'sfGuardSecurityUser'));
}

i also overwrite the signIn function of sfDoctrineGuard like this

public function signIn($user, $remember = false, $con = null)
{
    parent::signIn($user, $remember, 开发者_开发问答$con);
    if($this->authenticated){
        $this->setAttribute('is_customer', true, 'sfGuardSecurityUser');
    }
}

i made the same for backend in apps\backend\lib\myUser.class.php but using is_admin, untill now everything is perfect, just that in the backend, when i'm going to edit a Job, the sfGuardSecurityUser in the session get lost, why, because the isAuthenticated() function that is called in this page, is the located in apps\frontend\lib\myUser.class.php, so when i try to change the page i get logged out, cuz isAuthenticated() function called is the located in apps\backend\lib\myUser.class.php, sounds rare, but it only happens in the edit page of the Jobs, now i'm stuck here, hope you all understand me, and to be more specific, when i go to the job/edit page and in the action i put a print_r($_SESSION), i can see this piece

[sfGuardSecurityUser] => Array
            (
                [user_id] => 1
                [is_admin] => 1
            )  

but if i reload the page, i can't see this piece anymore, so, when i try to change of page, i get logged out, and more, if i comment or remove the isAuthenticated from apps\frontend\lib\myUser.class.php everything in the backend is perfect, but i need to overwrite the function in the backend and frontend

need some help

thanks


Try setting exact session names in your apps' factories.yml:

all:
  storage:
      class: sfSessionStorage
      param:
        session_name: my_session_name
        session_cookie_domain: example.com
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜