Пример #1
0
 /** @test */
 public function should_provide_valid_token()
 {
     $encoded_token = EncodedToken::fromNative('token');
     $this->jsonTokenService->shouldReceive('encode')->andReturn($encoded_token);
     $token = $this->tokenService->requestAccessToken($this->user);
     $this->assertInstanceOf(EncodedToken::class, $token);
 }
Пример #2
0
 public function login(Request $request)
 {
     $credentials = $request->only(['email', 'password']);
     $user = $this->authService->loginWithCredentials($credentials);
     $encodedToken = $this->tokenService->requestAccessToken($user);
     $jsonUser = $this->jsonTransformer->item($user, new UserTransformer());
     return $this->respondOk(['user' => $jsonUser, 'token' => $encodedToken->toString()]);
 }