0

I have a trouble. My login method always returns false

       public async Task<Object> Login(UserLoginForm user)
{
    if (user.nick.Replace(" ", "") != "")
    {
        if (user.password.Replace(" ", "") != "")
        {
            Microsoft.AspNetCore.Identity.SignInResult res = await _sign.PasswordSignInAsync(user.nick, user.password, false, false);
            return  _sign.IsSignedIn(_sign.Context.User);
        }
        else
        {
            HttpContext.Session.SetString("log", "p");
        }
    }
    else
        HttpContext.Session.SetString("log", "e");

    return RedirectToAction(nameof(Login));

}

Its method registration

public async Task<ActionResult> Registration(UserRegisForm user)
{
    if (user.name.Replace(" ", "") != "")
    {
        if (user.email.Replace(" ", "") != "" && user.email.Length > 5)
        {
            if(user.nik.Replace(" ", "") != "" && user.nik.Length > 4)
            {
                User usern = new User(user.name, user.second, 0, 0, 0, UserType.Standart) { Email = user.email, UserName = user.nik};
                IdentityResult res =  await _users.CreateAsync(usern, user.password);
                if (res.Succeeded)
                {
                    HttpContext.Session.SetString("reg", "s");
                }
                else
                {
                    HttpContext.Session.SetString("reg", res.Errors.First().Description);
                }
            }
            else
                HttpContext.Session.SetString("reg", "n");
        }
        else
            HttpContext.Session.SetString("reg", "e");
    }
    else
        HttpContext.Session.SetString("reg", "na");

    return RedirectToAction(nameof(Registration));
}

I dont understand why login always returns false. Can you help me get user data, and help to understand why its returns that value?

0 Answers0