Пример #1
0
 public function login($username, $password)
 {
     $this->addWhere('username', $username);
     $user = $this->getItem();
     $user->loadRole();
     if ($user !== \null && Security::verity($password, $user['password'])) {
         Auth::getInstance()->setIdentity($user);
         return \true;
     }
     return \false;
 }
Пример #2
0
 public function indexAction()
 {
     $exception = $this->request->getParam('exception');
     if (!$exception instanceof \Exception) {
         return ['exception' => $exception, 'message' => static::ERROR];
     }
     $code = $exception->getCode() ?: 404;
     $message = env('development') || $code === 403 ? $exception->getMessage() : static::ERROR;
     if ($this->request->isAjax()) {
         return new JsonResponse(['error' => ['message' => $exception->getMessage(), 'code' => $exception->getCode(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => $exception->getTrace()]], $code);
     }
     if ($exception->getCode() === 403) {
         if (Auth::identity() === \null) {
             if (is_allowed(app('router')->getRoute('admin-login')->getHandler())) {
                 return new RedirectResponse(route('admin-login', ['backTo' => urlencode(route())]));
             }
         }
     }
     $this->response->setCode($code);
     return ['exception' => $exception, 'message' => $message];
 }
Пример #3
0
 /**
  * (non-PHPdoc)
  * @see \Micro\Database\Table\Row\RowAbstract::save()
  */
 public function save()
 {
     if ($this->_table) {
         $cols = $this->_table->info(TableAbstract::COLS);
     } else {
         $cols = array();
     }
     if (empty($this->_cleanData) && in_array('created', $cols)) {
         $this->created = new Expr('NOW()');
     }
     if (in_array('edited', $cols)) {
         $this->edited = new Expr('NOW()');
     }
     $identity = Auth::identity();
     if ($identity instanceof Identity) {
         if (in_array('owner', $cols) && (empty($this->_cleanData) || !$this->owner)) {
             $this->owner = $identity->getId();
         }
         if (in_array('editor', $cols)) {
             $this->editor = $identity->getId();
         }
     }
     return parent::save();
 }
Пример #4
0
 public function logoutAction()
 {
     Auth::getInstance()->clearIdentity();
     return new RedirectResponse(route('admin', [], \true));
 }
Пример #5
0
 /**
  * @param unknown $force
  * @return \Micro\Auth\Identity
  */
 function identity($force = \false)
 {
     return Auth::identity($force);
 }