コード例 #1
0
        public async Task <LoginAuthResponseView> Login(LoginAuthView model)
        {
            SignInResult result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, false, false);

            if (!result.Succeeded)
            {
                throw new Exception("Invalid Login or password");
            }

            var user = await _userManager.FindByEmailAsync(model.Email);

            var encodedJwt = await _jwtProvider.GenerateJwtToken(user);

            var response = new LoginAuthResponseView()
            {
                Token = encodedJwt
            };

            return(response);
        }
コード例 #2
0
        public async Task <IActionResult> Login(LoginAuthView model)
        {
            var response = await _authService.Login(model);

            return(Ok(response));
        }