Skip to content

Commit

Permalink
fix: fix oauth login bad credentials (#4688)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Dec 12, 2020
1 parent 65cde10 commit 28d4cc9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### Fixes:

* Fix update activity with emotions
* Fix bad return with wrong credential on oauth/login api


# RELEASED VERSIONS:
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/Auth/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function login(Request $request): ?Response
return Route::respondWithRoute('oauth.verify');
}

return null;
return $this->respondUnauthorized();
}

/**
Expand Down
35 changes: 35 additions & 0 deletions tests/Browser/Auth/AuthControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,41 @@ public function test_oauth_login()
}
}

public function test_oauth_login_bad_password()
{
$repository = new ClientRepository();
$client = null;
try {
$client = $repository->createPasswordGrantClient(
null, config('app.name'), config('app.url')
);

$this->setEnvironmentValue([
'PASSPORT_PERSONAL_ACCESS_CLIENT_ID' => $client->id,
'PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET' => $client->secret,
]);

$userPassword = 'password';
$user = factory(User::class)->create([
'password' => bcrypt($userPassword),
]);

$response = $this->postClient(self::OAUTH_LOGIN_URL, [
'email' => $user->email,
'password' => 'wrongPassword',
]);

$this->expectNotAuthorized($response);
} finally {
if ($client) {
$repository->delete($client);
}
if ($user) {
$user->account->delete();
}
}
}

public function test_oauth_login_wrong_mail()
{
$response = $this->postClient(self::OAUTH_LOGIN_URL, [
Expand Down

0 comments on commit 28d4cc9

Please sign in to comment.