func MustChangePasswordPost(ctx *context.Context) {
	form := web.GetForm(ctx).(*forms.MustChangePasswordForm)
	ctx.Data["Title"] = ctx.Tr("auth.must_change_password")
	ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/settings/change_password"
	if ctx.HasError() {
		ctx.HTML(http.StatusOK, tplMustChangePassword)
		return
	}
	u := ctx.User
	// Make sure only requests for users who are eligible to change their password via
	// this method passes through
	if !u.MustChangePassword {
		ctx.ServerError("MustUpdatePassword", errors.New("cannot update password.. Please visit the settings page"))
		return
	}

	if form.Password != form.Retype {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplMustChangePassword, &form)
		return
	}

	if len(form.Password) < setting.MinPasswordLength {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplMustChangePassword, &form)
		return
	}

	var err error
	if err = u.SetPassword(form.Password); err != nil {
		ctx.ServerError("UpdateUser", err)
		return
	}

	u.MustChangePassword = false

	if err := models.UpdateUserCols(u, "must_change_password", "passwd", "passwd_hash_algo", "salt"); err != nil {
		ctx.ServerError("UpdateUser", err)
		return
	}

	ctx.Flash.Success(ctx.Tr("settings.change_password_success"))

	log.Trace("User updated password: %s", u.Name)

	if redirectTo := ctx.GetCookie("redirect_to"); len(redirectTo) > 0 && !utils.IsExternalURL(redirectTo) {
		middleware.DeleteRedirectToCookie(ctx.Resp)
		ctx.RedirectToFirst(redirectTo)
		return
	}

	ctx.Redirect(setting.AppSubURL + "/")
}
// MustChangePasswordPost response for updating a user's password after his/her
// account was created by an admin
MustChangePasswordPost response for updating a user's password after his/her
account was created by an admin
// MustChangePasswordPost response for updating a user ' s password after his / her // account was created by an admin
func MustChangePasswordPost(ctx *context.Context) {
	form := web.GetForm(ctx).(*forms.MustChangePasswordForm)
	ctx.Data["Title"] = ctx.Tr("auth.must_change_password")
	ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/settings/change_password"
	if ctx.HasError() {
		ctx.HTML(http.StatusOK, tplMustChangePassword)
		return
	}
	u := ctx.User
	if !u.MustChangePassword {
		ctx.ServerError("MustUpdatePassword", errors.New("cannot update password.. Please visit the settings page"))
		return
	}
	if form.Password != form.Retype {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplMustChangePassword, &form)
		return
	}
	if len(form.Password) < setting.MinPasswordLength {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplMustChangePassword, &form)
		return
	}
	var err error
	if err = u.SetPassword(form.Password); err != nil {
		ctx.ServerError("UpdateUser", err)
		return
	}
	u.MustChangePassword = false
	if err := models.UpdateUserCols(u, "must_change_password", "passwd", "passwd_hash_algo", "salt"); err != nil {
		ctx.ServerError("UpdateUser", err)
		return
	}
	ctx.Flash.Success(ctx.Tr("settings.change_password_success"))
	log.Trace("User updated password: %s", u.Name)
	if redirectTo := ctx.GetCookie("redirect_to"); len(redirectTo) > 0 && !utils.IsExternalURL(redirectTo) {
		middleware.DeleteRedirectToCookie(ctx.Resp)
		ctx.RedirectToFirst(redirectTo)
		return
	}
	ctx.Redirect(setting.AppSubURL + "/")
}
func MustChangePasswordPost ( ctx * context . Context ) { form := web . GetForm ( ctx ) . ( * forms . MustChangePasswordForm ) ctx . Data [ " " ] = ctx . Tr ( " " ) ctx . Data [ " " ] = setting . AppSubURL + " " if ctx . HasError ( ) { ctx . HTML ( http . StatusOK , tplMustChangePassword ) return } u := ctx . User if ! u . MustChangePassword { ctx . ServerError ( " " , errors . New ( " " ) ) return } if form . Password != form . Retype { ctx . Data [ " " ] = true ctx . RenderWithErr ( ctx . Tr ( " " ) , tplMustChangePassword , & form ) return } if len ( form . Password ) < setting . MinPasswordLength { ctx . Data [ " " ] = true ctx . RenderWithErr ( ctx . Tr ( " " , setting . MinPasswordLength ) , tplMustChangePassword , & form ) return } var err error if err = u . SetPassword ( form . Password ) ; err != nil { ctx . ServerError ( " " , err ) return } u . MustChangePassword = false if err := models . UpdateUserCols ( u , " " , " " , " " , " " ) ; err != nil { ctx . ServerError ( " " , err ) return } ctx . Flash . Success ( ctx . Tr ( " " ) ) log . Trace ( " " , u . Name ) if redirectTo := ctx . GetCookie ( " " ) ; len ( redirectTo ) > 0 && ! utils . IsExternalURL ( redirectTo ) { middleware . DeleteRedirectToCookie ( ctx . Resp ) ctx . RedirectToFirst ( redirectTo ) return } ctx . Redirect ( setting . AppSubURL + " " ) }
MustChangePasswordPost response for updating a user's password after his/her
account was created by an admin
MustChangePasswordPost response for updating a user ' s password after his / her account was created by an admin
// Make sure only requests for users who are eligible to change their password via // this method passes through