예제 #1
0
        public ActionResult ShortcutSignIn(string phone, string code)
        {
            if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(code))
            {
                return(Json(new { Success = false, Message = "手机号和验证码不能为空" }));
            }

            var entity = new AccountSign()
            {
                MobilePhone    = phone,
                ValidationCode = code
            };

            var signResult = new AccountController().ShortcutSignIn(entity);

            if (signResult.SignStatus != SignStatus.Success)
            {
                return(Json(new { Success = false, Message = "验证码错误" }));
            }

            var account = AnonymousAccount.FindLastByPassport(signResult.Account.PassportId);

            if (account == null)
            {
                return(Json(new { Success = false, Message = "Token已失效" }));
            }

            CookieHelper.SetCookie(AccountAuthentication.TokenKey, account.Token.AccessToken);
            return(Json(new { Success = true, Message = "登陆成功" }));
        }
예제 #2
0
        public ActionResult SignIn(string phone, string password)
        {
            if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(password))
            {
                return(Json(new { Success = false, Message = "手机号和密码不能为空" }));
            }

            var entity = new AccountSign()
            {
                MobilePhone = phone,
                Password    = password
            };

            UserPassport userPassport = null;
            var          success      = AccountAuthentication.SignIn(phone, password, null, out userPassport);

            if (!success)
            {
                return(Json(new { Success = false, Message = "手机号或密码错误" }));
            }

            var account = AnonymousAccount.FindLastByPassport(userPassport.PassportId);

            if (account == null)
            {
                return(Json(new { Success = false, Message = "Token已失效" }));
            }

            CookieHelper.SetCookie(AccountAuthentication.TokenKey, account.Token.AccessToken);
            return(Json(new { Success = true, Message = "登陆成功" }));
        }