Disable changing password for LDAP users

This commit is contained in:
cuigh 2017-11-09 19:46:53 +08:00
parent 415d92fede
commit 32d66e3de6
4 changed files with 14 additions and 4 deletions

View File

@ -168,4 +168,5 @@ profile.title: Profile
profile.description: User profiles. profile.description: User profiles.
profile.field.password.current: Current password profile.field.password.current: Current password
profile.field.password.new: New password profile.field.password.new: New password
profile.field.password.confirm: Password confirmation profile.field.password.confirm: Password confirmation
profile.password.warning: You are a LDAP user, can not modify password here.

View File

@ -168,4 +168,5 @@ profile.title: 资料
profile.description: 用户个人信息。 profile.description: 用户个人信息。
profile.field.password.current: 当前密码 profile.field.password.current: 当前密码
profile.field.password.new: 新密码 profile.field.password.new: 新密码
profile.field.password.confirm: 新密码确认 profile.field.password.confirm: 新密码确认
profile.password.warning: 你是 LDAP 认证用户,不支持在这里修改密码。

View File

@ -45,7 +45,12 @@ func profileModifyInfo(ctx web.Context) error {
} }
func profilePassword(ctx web.Context) error { func profilePassword(ctx web.Context) error {
m := newModel(ctx) user, err := biz.User.GetByID(ctx.User().ID())
if err != nil {
return err
}
m := newModel(ctx).Set("User", user)
return ctx.Render("profile/password", m) return ctx.Render("profile/password", m)
} }

View File

@ -65,9 +65,12 @@
<hr> <hr>
<div class="field"> <div class="field">
<p class="control"> <p class="control">
<button class="button is-primary" type="submit">{{ i18n("button.update") }}</button> <button class="button is-primary" type="submit"{{ if .User.Type == "ldap" }} disabled{{ end }}>{{ i18n("button.update") }}</button>
</p> </p>
</div> </div>
{{ if .User.Type == "ldap" }}
<div class="notification is-warning" style="margin-top: 1.5em">{{ i18n("profile.password.warning") }}</div>
{{ end }}
</div> </div>
</form> </form>
</div> </div>