Esempio n. 1
0
        public async Task <IActionResult> AuthenticateUserAsync([FromBody] ToDoUserLogin loginCredentials)
        {
            var result = await _signInManager.PasswordSignInAsync(loginCredentials.userName, loginCredentials.password, true, false);

            {
                if (result.Succeeded)
                {
                    return(LocalRedirect("/"));
                }
                else
                {
                    return(Unauthorized());
                }
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> CreateUserAsync([FromBody] ToDoUserLogin loginCredentials)
        {
            var result = await _userManager.CreateAsync(new ToDoUser()
            {
                UserName = loginCredentials.userName
            }, loginCredentials.password);

            if (result.Succeeded)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }