root/trunk/apps/main/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php

Revision 53, 1.8 kB (checked in by nperriault, 2 years ago)
  • Ported signin form and action to 1.1 forms framework
  • lib folder layout changed
Line 
1 <?php
2 /**
3  * Base sfGuardAuth actions
4  *
5  * @package    symfony
6  * @subpackage plugin
7  */
8 class BasesfGuardAuthActions extends myActions
9 {
10   public function executeSignin(sfWebRequest $request)
11   {
12     $user = $this->getUser();
13     if ($user->isAuthenticated())
14     {
15       return $this->redirect('@homepage');
16     }
17
18     $this->form = new SigninForm();
19
20     if ($request->isMethod('post'))
21     {
22       $this->form->bind($request->getParameter('signin'));
23       
24       if ($this->form->isValid())
25       {
26         $values = $this->form->getValues();
27         $this->getUser()->signin($values['user'], 'on' === $values['remember']);
28
29         $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user->getReferer($request->getReferer()));
30
31         return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage');
32       }
33     }
34     else
35     {
36       if ($request->isXmlHttpRequest())
37       {
38         $this->getResponse()->setHeaderOnly(true);
39         $this->getResponse()->setStatusCode(401);
40
41         return sfView::NONE;
42       }
43
44       $user->setReferer($request->getReferer());
45
46       $module = sfConfig::get('sf_login_module');
47       if ($this->getModuleName() != $module)
48       {
49         return $this->redirect($module.'/'.sfConfig::get('sf_login_action'));
50       }
51
52       $this->getResponse()->setStatusCode(401);
53     }
54   }
55
56   public function executeSignout(sfWebRequest $request)
57   {
58     $this->getUser()->signOut();
59
60     $signout_url = sfConfig::get('app_sf_guard_plugin_success_signout_url', $request->getReferer());
61
62     $this->redirect('' != $signout_url ? $signout_url : '@homepage');
63   }
64
65   public function executeSecure()
66   {
67     $this->getResponse()->setStatusCode(403);
68   }
69
70   public function executePassword()
71   {
72     throw new sfException('This method is not yet implemented.');
73   }
74 }
75
Note: See TracBrowser for help on using the browser.