Example #1
0
 /**
  * Forgery constructor
  */
 public function __forge()
 {
     $user = \Magelight\Auth\Models\User::find(\Magelight\Http\Request::getInstance()->getGet('id'));
     if ($user) {
         $this->set('user', $user->asArray());
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function initBlock()
 {
     $currentUserId = \Magelight\Http\Session::getInstance()->get('user_id', false);
     if ($currentUserId && ($userData = \Magelight\Auth\Models\User::find($currentUserId)->asArray())) {
         $this->set('user_id', $currentUserId);
         $this->set('user_data', $userData);
     }
     return parent::initBlock();
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function initBlock()
 {
     $currentUserId = \Magelight\Http\Session::getInstance()->get('user_id');
     if (!empty($currentUserId)) {
         if ($user = \Magelight\Auth\Models\User::find($currentUserId)) {
             $userData = $user->asArray();
             $this->setGlobal('user_data', $userData);
         }
     }
     $document = \Magelight\Core\Blocks\Document::getInstance();
     $document->addMeta(['http-equiv' => "content-type", 'content' => "text/html; charset=utf-8"]);
     $document->addCss('Magelight/Core/static/css/bootstrap.css');
     $document->addCss('Magelight/Core/static/css/hint.css');
     $document->addJs('Magelight/Core/static/js/jquery.js');
     $document->addJs('Magelight/Core/static/js/bootstrap.min.js');
     return parent::initBlock();
 }
Example #4
0
 /**
  * Login via uLogin service action handler
  */
 public function serviceloginAction()
 {
     $s = file_get_contents('http://ulogin.ru/token.php?token=' . $this->request()->getPost('token') . '&host=' . \Magelight\Http\Server::getInstance()->getCurrentDomain());
     $userData = json_decode($s, true);
     $user = \Magelight\Auth\Models\User::forge()->authorizeViaUlogin($userData);
     if (!$user) {
         $user = \Magelight\Auth\Models\User::forge()->createViaUlogin($userData, $this->url(\Magelight\Config::getInstance()->getConfig('global/auth/avatar/noavatar_url')));
     }
     if ($user) {
         $this->session()->set('user_id', $user->id);
         $this->redirect($this->url(\Magelight\Config::getInstance()->getConfig('global/auth/urls/success_url')));
     } else {
         $this->redirect($this->url(\Magelight\Config::getInstance()->getConfig('global/auth/urls/openauth_error')));
     }
 }