Example #1
0
 public function checkJWT()
 {
     $para = $this->_requestValidData[XIIS_PARAMS_CONF_JWT];
     $valid = XiiJwt::verifyJwt($para);
     if (is_numeric($valid)) {
         self::sendError($valid);
     } else {
         self::$_authUserData = $valid;
     }
 }
Example #2
0
 protected function generateJwt($user, $success = EC_BACKEND_SUCCESS_LOGIN)
 {
     $para = ['header' => ['typ' => 'JWT', 'alg' => XIIS_PARAMS_CONF_JWT_ALG]];
     foreach (self::$_jwtPayload as $v) {
         if (!isset($user[$v])) {
             self::sendError(EC_BACKEND_FAIL_TO_CREATE_PAYLOAD);
         }
         $payload[$v] = $user[$v];
     }
     $payload['iat'] = $payload['nbf'] = $payload['exp'] = time();
     $payload['exp'] += XIIS_PARAMS_CONF_JWT_EXP;
     $para['payload'] = $payload;
     $feedback = [XIIS_FEEDBACK_STATUS => true, XIIS_FEEDBACK_CODE => $success, XIIS_FEEDBACK_MSG => XiiError::getErrorMessage($success), XIIS_FEEDBACK_DATA => [XIIS_PARAMS_CONF_JWT => XiiJwt::getJWT($para)]];
     return $feedback;
 }