| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
class BasesfGuardAuthActions extends sfActions |
|---|
| 19 |
{ |
|---|
| 20 |
public function executeSignin($request) |
|---|
| 21 |
{ |
|---|
| 22 |
$user = $this->getUser(); |
|---|
| 23 |
if ($user->isAuthenticated()) |
|---|
| 24 |
{ |
|---|
| 25 |
return $this->redirect('@homepage'); |
|---|
| 26 |
} |
|---|
| 27 |
|
|---|
| 28 |
if ($request->isXmlHttpRequest()) |
|---|
| 29 |
{ |
|---|
| 30 |
$this->getResponse()->setHeaderOnly(true); |
|---|
| 31 |
$this->getResponse()->setStatusCode(401); |
|---|
| 32 |
|
|---|
| 33 |
return sfView::NONE; |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
$class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin'); |
|---|
| 37 |
$this->form = new $class(); |
|---|
| 38 |
|
|---|
| 39 |
if ($request->isMethod('post')) |
|---|
| 40 |
{ |
|---|
| 41 |
$this->form->bind($request->getParameter('signin')); |
|---|
| 42 |
if ($this->form->isValid()) |
|---|
| 43 |
{ |
|---|
| 44 |
$values = $this->form->getValues(); |
|---|
| 45 |
$this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false); |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
// or to the referer |
|---|
| 49 |
// or to the homepage |
|---|
| 50 |
$signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user->getReferer('@homepage')); |
|---|
| 51 |
|
|---|
| 52 |
return $this->redirect($signinUrl); |
|---|
| 53 |
} |
|---|
| 54 |
} |
|---|
| 55 |
else |
|---|
| 56 |
{ |
|---|
| 57 |
|
|---|
| 58 |
// if not, this is the referer of the current request |
|---|
| 59 |
$user->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer()); |
|---|
| 60 |
|
|---|
| 61 |
$module = sfConfig::get('sf_login_module'); |
|---|
| 62 |
if ($this->getModuleName() != $module) |
|---|
| 63 |
{ |
|---|
| 64 |
return $this->redirect($module.'/'.sfConfig::get('sf_login_action')); |
|---|
| 65 |
} |
|---|
| 66 |
} |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
public function executeSignout($request) |
|---|
| 70 |
{ |
|---|
| 71 |
$this->getUser()->signOut(); |
|---|
| 72 |
|
|---|
| 73 |
$signoutUrl = sfConfig::get('app_sf_guard_plugin_success_signout_url', $request->getReferer()); |
|---|
| 74 |
|
|---|
| 75 |
$this->redirect('' != $signoutUrl ? $signoutUrl : '@homepage'); |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
public function executeSecure() |
|---|
| 79 |
{ |
|---|
| 80 |
$this->getResponse()->setStatusCode(403); |
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
public function executePassword() |
|---|
| 84 |
{ |
|---|
| 85 |
throw new sfException('This method is not yet implemented.'); |
|---|
| 86 |
} |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|