Beispiel #1
0
        public async Task <ActionResult <UserToken> > Login([FromBody] dynamic userInfo)
        {
            var result = await _signInManager.PasswordSignInAsync((string)userInfo.Login, (string)userInfo.Password, isPersistent : false, lockoutOnFailure : false);

            if (result.Succeeded)
            {
                JWT jwt = new JWT(_roleManager, _userManager);
                return(await jwt.BuildTokenAsync((string)userInfo.Email, _configuration["jwt:key"]));
            }
            else
            {
                return(Unauthorized("Invalid credentials."));
            }
        }