當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AuthenticationException::getMessageKey方法代碼示例

本文整理匯總了PHP中Symfony\Component\Security\Core\Exception\AuthenticationException::getMessageKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP AuthenticationException::getMessageKey方法的具體用法?PHP AuthenticationException::getMessageKey怎麽用?PHP AuthenticationException::getMessageKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Security\Core\Exception\AuthenticationException的用法示例。


在下文中一共展示了AuthenticationException::getMessageKey方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onAuthenticationFailure

 /**
  * {@inheritdoc}
  */
 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     if ($request->isXmlHttpRequest()) {
         return new JsonResponse(['success' => false, 'message' => $exception->getMessageKey()], 401);
     }
     return parent::onAuthenticationFailure($request, $exception);
 }
開發者ID:gabiudrescu,項目名稱:Sylius,代碼行數:10,代碼來源:AuthenticationFailureHandler.php

示例2: start

 public function start(Request $request, AuthenticationException $authException = null)
 {
     $apiProblem = new ApiProblem(Response::HTTP_UNAUTHORIZED);
     $message = $authException ? $authException->getMessageKey() : 'Missing credentials';
     $apiProblem->set('detail', $message);
     return $this->responseFactory->createResponse($apiProblem);
 }
開發者ID:C3-TKO,項目名稱:smash-api,代碼行數:7,代碼來源:JWTTokenAuthenticator.php

示例3: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     return new JsonResponse(
         // you could translate the message
         array('message' => $exception->getMessageKey()),
         403
     );
 }
開發者ID:romainbellande,項目名稱:iim-notes,代碼行數:8,代碼來源:ApiTokenAuthenticator.php

示例4: onAuthenticationFailure

 /**
  * NOTE: I chose to throw an HTTP Exception here to let the response be rendered elsewhere -
  *       separation of concerns and all... You could always return a JsonResponse here.
  */
 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     $message = 'Invalid Credentials';
     if ($exception instanceof CustomUserMessageAuthenticationException) {
         $message = $exception->getMessageKey();
     }
     throw new HttpException(401, $message);
 }
開發者ID:tuimedia,項目名稱:forum,代碼行數:12,代碼來源:JWTAuthenticator.php

示例5: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     if ($request->isXmlHttpRequest()) {
         if ($this->env != 'dev') {
             $msg = $this->translator->trans($exception->getMessageKey(), $exception->getMessageData(), 'security');
         } else {
             $msg = $exception->getMessage();
         }
         return new JsonResponse($msg, Response::HTTP_UNAUTHORIZED);
     }
     return parent::onAuthenticationFailure($request, $exception);
 }
開發者ID:robstoll,項目名稱:PuMa,代碼行數:12,代碼來源:AuthFailureHandler.php

示例6: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     if ($request->isXmlHttpRequest()) {
         $message = $exception->getMessageKey();
         $messageTrans = $this->translator->trans($message, array(), 'FOSUserBundle');
         if ($messageTrans === $message) {
             $messageTrans = $this->translator->trans($message, array(), 'security');
         }
         $data = array('message' => $messageTrans);
         $response = new \Symfony\Component\HttpFoundation\JsonResponse($data, 400);
         return $response;
     } else {
         return parent::onAuthenticationFailure($request, $exception);
     }
 }
開發者ID:bambamboole,項目名稱:AjaxFOSUserBundle,代碼行數:15,代碼來源:AuthenticationFailureHandler.php

示例7: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     // TODO: Implement onAuthenticationFailure() method.
     return new JsonResponse(array('message' => $exception->getMessageKey()), 403);
 }
開發者ID:Benjamin57,項目名稱:iim-notes-DARCET-ACHEEN-CARCAGNO,代碼行數:5,代碼來源:ApiTokenAuthenticator.php

示例8:

 function it_returns_json_response_if_request_is_xml_based(Request $request, AuthenticationException $authenticationException)
 {
     $request->isXmlHttpRequest()->willReturn(true);
     $authenticationException->getMessageKey()->willReturn('Invalid credentials.');
     $this->onAuthenticationFailure($request, $authenticationException)->shouldHaveType(JsonResponse::class);
 }
開發者ID:loic425,項目名稱:Sylius,代碼行數:6,代碼來源:AuthenticationFailureHandlerSpec.php

示例9: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     throw new \Exception();
     return new Response(strtr($exception->getMessageKey(), $exception->getMessageData()), 403);
 }
開發者ID:koala-framework,項目名稱:koala-framework,代碼行數:5,代碼來源:KwfUserAuthenticator.php

示例10: getMessageKey

 public function getMessageKey()
 {
     return $this->messageKey !== null ? $this->messageKey : parent::getMessageKey();
 }
開發者ID:Irvyne,項目名稱:KnpUGuard,代碼行數:4,代碼來源:CustomAuthenticationException.php

示例11: createResponseFromException

 /**
  * Create a proper json response containing the error.
  *
  * @param AuthenticationException $authException The exception that started the authentication process.
  *
  * @return JsonResponse
  */
 private function createResponseFromException(AuthenticationException $authException = null)
 {
     $data = ['status' => 'unauthorized'];
     if ($authException) {
         $data['message'] = $authException->getMessageKey();
     }
     return new JsonResponse($data, JsonResponse::HTTP_UNAUTHORIZED);
 }
開發者ID:contao,項目名稱:package-manager,代碼行數:15,代碼來源:PostDataAuthenticator.php

示例12: onAuthenticationFailure

 /**
  * Called when authentication executed, but failed (e.g. wrong username password).
  *
  * This should return the Response sent back to the user, like a
  * RedirectResponse to the login page or a 403 response.
  *
  * If you return null, the request will continue, but the user will
  * not be authenticated. This is probably not what you want to do.
  *
  * @param Request $request
  * @param AuthenticationException $exception
  *
  * @return Response|null
  */
 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     return new JsonResponse(['message' => $this->translator->trans($exception->getMessageKey(), $exception->getMessageData())], 403);
 }
開發者ID:robertdumitrescu,項目名稱:Interview-MusicCoursesApplication,代碼行數:18,代碼來源:TokenAuthenticatorService.php

示例13: onAuthenticationFailure

 /**
  * This is called when an interactive authentication attempt fails. This is
  * called by authentication listeners inheriting from
  * AbstractAuthenticationListener.
  *
  * @param Request $request
  * @param AuthenticationException $exception
  *
  * @return Response The response to return, never null
  */
 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     $data = array('code' => self::RESPONSE_FAILURE_CODE, 'message' => strtr($exception->getMessageKey(), $exception->getMessageData()));
     return new JsonResponse($data, self::RESPONSE_FAILURE_CODE);
 }
開發者ID:coresite,項目名稱:apiauthbundle,代碼行數:15,代碼來源:ApiKeyAuthenticator.php

示例14: onAuthenticationFailure

 /**
  * @inheritDoc
  */
 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     return new JsonResponse(['message' => $exception->getMessageKey()], 401);
 }
開發者ID:ampisoft,項目名稱:user-bundle,代碼行數:7,代碼來源:ApiTokenAuthenticator.php

示例15: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     $data = array('message' => strtr($exception->getMessageKey(), $exception->getMessageData()));
     return new JsonResponse($data, 403);
 }
開發者ID:sujit13666,項目名稱:SymfonyCRUD,代碼行數:5,代碼來源:TokenAuthenticator.php


注:本文中的Symfony\Component\Security\Core\Exception\AuthenticationException::getMessageKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。