示例#1
0
        public async Task <SignInResult> PasswordSignInAsync(IdentityUser user, string password)
        {
            var result = await signInManager.PasswordSignInAsync(user, password, true, true);

            if (result.Succeeded)
            {
                return(await SignInResultAsync(user));
            }
            return(SignInResult.Failed("登录失败"));
        }
示例#2
0
        public async Task <IActionResult> Auth([FromBody] LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                //ResponseResult responseResult = VCheakCode(model.Code);
                //if (!responseResult.Succeeded)
                //{
                //    return Json(responseResult);
                //}
                var user = await tokenManager.GetUserAsync(model.ByPhone, model.Email, model.Phone);

                if (user != null)
                {
                    if (model.ByPhone)
                    {
                        if (!user.PhoneNumberConfirmed)
                        {
                            return(Json(SignInResult.PhoneNumberConfirmed));
                        }
                    }
                    else
                    {
                        if (!user.EmailConfirmed)
                        {
                            return(Json(SignInResult.EmailConfirmed));
                        }
                    }
                    var result = await tokenManager.PasswordSignInAsync(user, model.Password);

                    return(Json(result));
                }
                else
                {
                    return(Json(SignInResult.Failed("用户名或者密码错误!")));
                }
            }
            return(Failed());
        }