say NO to try-catch in controllers
- added ExceptionsMiddleware.cs - added more Exception types - removed all exceptions logic in controllers
This commit is contained in:
parent
eb271793ad
commit
55e82425a9
8 changed files with 75 additions and 20 deletions
|
|
@ -16,12 +16,12 @@ public class AuthorizationService : IAuthorizationService
|
|||
_passwordHasher = passwordHasher;
|
||||
}
|
||||
|
||||
public async Task<string?> LogInUser(string email, string password)
|
||||
public async Task<string> LogInUser(string email, string password)
|
||||
{
|
||||
var user = await _userService.GetUserByEmail(email);
|
||||
if (user is null || !_passwordHasher.Verify(password, user.Password))
|
||||
if (!_passwordHasher.Verify(password, user.Password))
|
||||
{
|
||||
throw new UnauthorizedException("Email or password is incorrect.");
|
||||
throw new UnauthorizedException("Password is incorrect.");
|
||||
}
|
||||
|
||||
var token = TokenHelper.GetAuthToken(user);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue