diff options
Diffstat (limited to 'Logics/CreateUserAccountSessionLogic.cs')
-rw-r--r-- | Logics/CreateUserAccountSessionLogic.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Logics/CreateUserAccountSessionLogic.cs b/Logics/CreateUserAccountSessionLogic.cs new file mode 100644 index 0000000..2e51791 --- /dev/null +++ b/Logics/CreateUserAccountSessionLogic.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Identity; +using BackendPIA.Services; +using BackendPIA.Models; +using BackendPIA.Forms; + +namespace BackendPIA.Logics { + public class CreateUserAccountSessionLogic : BaseUserAccountLogic { + private readonly UserAccountLoginForm _form; + + public CreateUserAccountSessionLogic(ITokenGenerator token_generator, UserManager<UserAccount> manager, UserAccountLoginForm form) : base(token_generator, manager) { + _form = form; + } + + public async Task<bool> Call() { + var user = await _manager.FindByEmailAsync(_form.Email); + + if(user == null ) + return false; + + var result = await _manager.CheckPasswordAsync(user, _form.Password); + + if(result) { + await SetAuthenticationToken(user); + + return true; + } + + return false; + } + } +}
\ No newline at end of file |