コード例 #1
0
ファイル: UserService.cs プロジェクト: thatismatt/AjaxLogIn
 public void CreateUser(SignUpModel model)
 {
     if (s_UsersToPasswords.ContainsKey(model.Email))
     {
         throw new Exception("User already exists.");
     }
     s_UsersToPasswords[model.Email] = model.Password;
 }
コード例 #2
0
        public JsonResult SignUp(SignUpModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    m_UserService.CreateUser(model);
                }
                catch (Exception e)
                {
                    return JsonSuccess(new { IsRegistered = false, Error = e.Message });
                }

                const bool rememberMe = false;
                m_AuthService.SetAuthCookie(model.Email, rememberMe);
                return JsonSuccess(new { IsRegistered = true });
            }

            // If we got this far, something failed, redisplay form
            return JsonSuccess(new { IsRegistered = false, Error = "Invalid signup details." });
        }