Exemplo n.º 1
0
 public function logoutAction()
 {
     $this->session->destroy();
     Utils::tips('info', 'Logout Page');
 }
Exemplo n.º 2
0
 public function OTPAuthAction()
 {
     $redirect = $this->session->get('redirect');
     if (!$redirect) {
         header('Location: /api/sso/login');
         exit;
     }
     if ($_POST) {
         $code = $this->request->get('code', 'int');
         $user_id = $this->session->get('user_id');
         $user = $this->authModel->getUser($user_id);
         $otp = new PHPGangsta_GoogleAuthenticator();
         $checkResult = $otp->verifyCode($user['secret_key'], $code, 2);
         // 2 = 2*30sec clock tolerance
         $this->session->set('redirect', null);
         if (!$checkResult) {
             Utils::tips('warning', 'Authenticator Code Is Error');
         }
         $this->session->set('isLogin', 1);
         header("Location:" . $redirect);
         exit;
     }
     $this->view->pick('sso/OTPAuth');
 }