/** * Authenticates user by e-mail address * * @param $email * @return mixed * @throws IdentityNotFoundException */ public function authenticateByEmail($email) { $user = BaseUser::findFirst([['email' => $email]]); if (!$user) { throw new IdentityNotFoundException(); } $adapter = new \Vegas\Security\Authentication\Adapter\NoCredential($this->di->get('userPasswordManager')); $adapter->setSessionStorage($this->obtainSessionScope()); $auth = new Authentication($adapter); $auth->authenticate($user, null); return $auth->getIdentity(); }
$sessionAdapter = new SessionAdapter($config->session->toArray()); if (!$sessionAdapter->isStarted()) { $sessionAdapter->start(); } return $sessionAdapter; }, true); $di->set('sessionManager', function () use($di) { $session = new Vegas\Session($di->get('session')); return $session; }, true); /** * Password manager for standard user */ $di->set('userPasswordManager', '\\Vegas\\Security\\Password\\Adapter\\Standard', true); /** authentications **/ //standard user $di->set('auth', function () use($di) { $adapter = new \Vegas\Security\Authentication\Adapter\Standard($di->get('userPasswordManager')); $adapter->setSessionStorage($di->get('sessionManager')->createScope('auth')); $auth = new \Vegas\Security\Authentication($adapter); return $auth; }, true); //no credential $di->set('authNoCredential', function () use($di) { $adapter = new \Vegas\Security\Authentication\Adapter\NoCredential(); $adapter->setSessionStorage($di->get('sessionManager')->createScope('authUser')); $auth = new \Vegas\Security\Authentication($adapter); return $auth; }, true); require "fixtures/BaseUser.php"; \Phalcon\DI::setDefault($di);