예제 #1
0
 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." });
        }