Ejemplo n.º 1
0
        public ActionResult SignUp(string email, string password)
        {
            if (!PasswordTools.IsSecurePassword(password))
            {
                return(Json(new ChalkableException("Your password is not secure enough")));
            }

            var sysLocator = ServiceLocatorFactory.CreateMasterSysAdmin();

            if (sysLocator.UserService.GetByLogin(email) != null)
            {
                return(Json(new ChalkableException(ChlkResources.ERR_SIGNUP_USER_WITH_EMAIL_ALREADY_EXISTS)));
            }

            sysLocator.DeveloperService.Add(email, password, null, null, null);
            return(LogOn(email, password, false));
        }
Ejemplo n.º 2
0
        public ActionResult ChangePassword(string oldPassword, string newPassword, string newPasswordConfirmation, bool resetPassword)
        {
            if (!PasswordTools.IsSecurePassword(newPassword))
            {
                return(Json(new ChalkableException("new password is not secure enough")));
            }

            var login = Context.Login;

            if (!resetPassword && MasterLocator.UserService.Login(login, oldPassword) == null)
            {
                return(Json(new ChalkableException("old password is incorrect")));
            }

            if (newPassword != newPasswordConfirmation)
            {
                return(Json(new ChalkableException("new password and confirmation doesn't match")));
            }

            MasterLocator.UserService.ChangePassword(login, newPassword);
            MasterLocator.UserTrackingService.ChangedPassword(Context.Login);
            return(Json(true));
        }