From ff42bfdd777841d9576866c1849bfb29beb3b0ce Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Sat, 21 Jul 2018 17:11:01 +0100 Subject: [PATCH] force users to change password if account was created by an admin --- models/migrations/v71.go | 18 ++++++++++++++ templates/user/auth/change_passwd.tmpl | 7 ++++++ templates/user/auth/change_passwd_inner.tmpl | 26 ++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 models/migrations/v71.go create mode 100644 templates/user/auth/change_passwd.tmpl create mode 100644 templates/user/auth/change_passwd_inner.tmpl diff --git a/models/migrations/v71.go b/models/migrations/v71.go new file mode 100644 index 000000000..87e7a71aa --- /dev/null +++ b/models/migrations/v71.go @@ -0,0 +1,18 @@ +// Copyright 2018 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package migrations + +import ( + "github.com/go-xorm/xorm" +) + +func addMustChangePassword(x *xorm.Engine) error { + type User struct { + ID int64 `xorm:"pk autoincr"` + MustChangePassword bool `xorm:"NOT NULL DEFAULT false"` + } + + return x.Sync2(new(User)) +} diff --git a/templates/user/auth/change_passwd.tmpl b/templates/user/auth/change_passwd.tmpl new file mode 100644 index 000000000..d84796348 --- /dev/null +++ b/templates/user/auth/change_passwd.tmpl @@ -0,0 +1,7 @@ +{{template "base/head" .}} +
+
+ {{template "user/auth/change_passwd_inner" .}} +
+
+{{template "base/footer" .}} diff --git a/templates/user/auth/change_passwd_inner.tmpl b/templates/user/auth/change_passwd_inner.tmpl new file mode 100644 index 000000000..60d4a210e --- /dev/null +++ b/templates/user/auth/change_passwd_inner.tmpl @@ -0,0 +1,26 @@ + {{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn)}} + {{template "base/alert" .}} + {{end}} +

+ {{.i18n.Tr "settings.change_password"}} +

+
+
+ {{.CsrfTokenHtml}} +
+ + +
+ + +
+ + +
+ +
+ + +
+
+