public async Task <ActionResult> ChangePasswordAsync(ChangePasswordInfo model)
        {
            var meta = await AppUsers.GetCurrentAsync(this.Tenant).ConfigureAwait(true);

            if (!meta.IsAdministrator)
            {
                return(this.AccessDenied());
            }

            if (!this.ModelState.IsValid)
            {
                return(this.InvalidModelState(this.ModelState));
            }


            if (model.Password != model.ConfirmPassword)
            {
                return(this.Failed(I18N.ConfirmPasswordDoesNotMatch, HttpStatusCode.BadRequest));
            }


            try
            {
                await ChangePasswordModel.ChangePasswordAsync(this.Tenant, model).ConfigureAwait(true);

                return(this.Ok("OK"));
            }
            catch (Exception ex)
            {
                return(this.Failed(ex.Message, HttpStatusCode.InternalServerError));
            }
        }
Esempio n. 2
0
        public async Task <ActionResult> PostAsync(ChangePassword model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.InvalidModelState(this.ModelState));
            }

            bool result = await ChangePasswordModel.ChangePasswordAsync(this.AppUser, model, this.RemoteUser).ConfigureAwait(true);

            return(this.Ok(result));
        }