Added models for presentation layer with data annotations
This commit is contained in:
		| @@ -1,19 +1,20 @@ | ||||
| using ApplicationLayer.Services.AuthServices.LoginService.Exceptions; | ||||
| using ApplicationLayer.Services.AuthServices.NeededServices; | ||||
| using ApplicationLayer.Services.AuthServices.Requests; | ||||
|  | ||||
| namespace ApplicationLayer.Services.AuthServices.LoginService; | ||||
|  | ||||
| /// <inheritdoc cref="ILoginService"/> | ||||
| /// <inheritdoc cref="ILoginService" /> | ||||
| public class LoginService(IUsersRepository users, ITokenGenerator tokenGenerator) : ILoginService | ||||
| { | ||||
|     async Task<string> ILoginService.LoginAsync(string email, string password, CancellationToken cancellationToken) | ||||
|     async Task<string> ILoginService.LoginAsync(LoginRequest request, CancellationToken cancellationToken) | ||||
|     { | ||||
|             var user = await users.FindByEmailAsync(email, cancellationToken); | ||||
|             if (user is null || user.Password != password) | ||||
|             { | ||||
|                 throw new IncorrectLoginDataException(); | ||||
|             } | ||||
|  | ||||
|             return tokenGenerator.CreateToken(user); | ||||
|         var user = await users.FindByEmailAsync(request.AuthData.Email, cancellationToken); | ||||
|         if (user is null || user.Password != request.AuthData.Password) | ||||
|         { | ||||
|             throw new IncorrectLoginDataException(); | ||||
|         } | ||||
| } | ||||
|  | ||||
|         return tokenGenerator.CreateToken(user); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user