Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 public function checkUnique()
 {
     if (count($this->_requestData) == 1) {
         $validCheck = in_array(key($this->_requestData), self::$_uniqueCheckAllowField);
     } else {
         $diff = array_diff(array_keys($this->_requestData), self::$_uniqueCheckAllowField);
         $validCheck = empty($diff) ? true : false;
     }
     if ($validCheck) {
         $feedback = $this->_model->countAll([XIIS_PARAMS_CONDITION => $this->_requestData]);
         if ($feedback[XIIS_FEEDBACK_STATUS] === false) {
             $status = true;
             $code = EC_BACKEND_UNIQUE_CHECK_YES;
         } else {
             $status = false;
             $code = EC_BACKEND_UNIQUE_CHECK_NO;
         }
         $msg = XiiError::getErrorMessage($code);
         self::$_outData = [XIIS_FEEDBACK_STATUS => $status, XIIS_FEEDBACK_CODE => $code, XIIS_FEEDBACK_MSG => $msg, XIIS_FEEDBACK_DATA => $this->_requestData];
     } else {
         self::sendError(EC_BACKEND_UNIQUE_INVALID_FIELD);
     }
 }
Exemplo n.º 3
0
 public function actionStatus()
 {
     self::$_outData = [XIIS_FEEDBACK_STATUS => true, XIIS_FEEDBACK_CODE => EC_AUTH_TOKEN_VERIFY_PASS, XIIS_FEEDBACK_MSG => XiiError::getErrorMessage(EC_AUTH_TOKEN_VERIFY_PASS), XIIS_FEEDBACK_DATA => []];
 }