Пример #1
0
        public async Task <IActionResult> Login([FromBody] ApiLoginModel model)
        {
            var user = await _userManager.FindByNameAsync(model.Username);

            if (user == null)
            {
                return(Unauthorized());
            }

            var loginResult = await _signInManager.CheckPasswordSignInAsync(user, model.Password, false);

            if (loginResult.Succeeded)
            {
                var tokenResult = await CreateTokenAndSignIn(user);

                // also sign in default scheme
                await SignInDefaultScheme(user);

                return(Ok(tokenResult));
            }

            return(Unauthorized());
        }