Beispiel #1
0
        public async Task <TokenResponse> SignInAsync(SignInRequest request, CancellationToken cancellationToken = default)
        {
            SignInResult signResult = await _userRespository.AuthenticateAsync(request.Email, request.Password, cancellationToken);

            if (!signResult.Succeeded)
            {
                throw new StackException("Wrong Passwort or Username");
            }

            User myUser = await _userRespository.GetByEmailAsync(request.Email);

            if (myUser == null)
            {
                throw new NotFoundException("user not found");
            }

            return(new TokenResponse
            {
                Token = GenerateSecurityToken(request, myUser)
            });
        }