コード例 #1
0
ファイル: Auth.php プロジェクト: Zacker/cli
 /**
  * Ensures the user is logged in or errs.
  *
  * @return [boolean] Always true
  */
 public static function ensureLogin()
 {
     $session = Session::instance()->getData();
     $auth = new Auth();
     if (!$auth->loggedIn()) {
         if (isset($session->refresh)) {
             $auth->logInViaMachineToken($session->refresh);
         } else {
             throw new TerminusException('Please login first with `terminus auth login`', array(), 1);
         }
     }
     return true;
 }
コード例 #2
0
ファイル: Auth.php プロジェクト: dalin-/cli
 /**
  * Ensures the user is logged in or errs.
  *
  * @return bool Always true
  * @throws TerminusException
  */
 public static function ensureLogin()
 {
     $session = Session::instance()->getData();
     $auth = new Auth();
     if (!$auth->loggedIn()) {
         if ($token = $auth->getOnlySavedToken()) {
             $auth->logInViaMachineToken($token);
         } else {
             if (isset($_SERVER['TERMINUS_MACHINE_TOKEN']) && ($token = $_SERVER['TERMINUS_MACHINE_TOKEN'])) {
                 $auth->logInViaMachineToken(compact('token'));
             } else {
                 if (isset($_SERVER['TERMINUS_USER']) && ($email = $_SERVER['TERMINUS_USER'])) {
                     $auth->logInViaMachineToken(compact('email'));
                 } else {
                     $message = 'You are not logged in. Run `auth login` to ';
                     $message .= 'authenticate or `help auth login` for more info.';
                     $auth->logger->warning($message);
                     exit(1);
                 }
             }
         }
     }
     return true;
 }
コード例 #3
0
ファイル: test-auth.php プロジェクト: barkinet/cli
 /**
  * @vcr auth_login_machine-token
  */
 public function testLogInViaMachineToken()
 {
     $passed = $this->auth->logInViaMachineToken(getBehatCredentials());
     $this->assertTrue($passed);
     setDummyCredentials();
 }