예제 #1
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());
        }