Skip to content

Commit ff42bfd

Browse files
committed
force users to change password if account was created by an admin
1 parent 23acb29 commit ff42bfd

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

models/migrations/v71.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2018 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"github.com/go-xorm/xorm"
9+
)
10+
11+
func addMustChangePassword(x *xorm.Engine) error {
12+
type User struct {
13+
ID int64 `xorm:"pk autoincr"`
14+
MustChangePassword bool `xorm:"NOT NULL DEFAULT false"`
15+
}
16+
17+
return x.Sync2(new(User))
18+
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{template "base/head" .}}
2+
<div class="user signin{{if .LinkAccountMode}} icon{{end}}">
3+
<div class="ui container">
4+
{{template "user/auth/change_passwd_inner" .}}
5+
</div>
6+
</div>
7+
{{template "base/footer" .}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{if or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn)}}
2+
{{template "base/alert" .}}
3+
{{end}}
4+
<h4 class="ui top attached header center">
5+
{{.i18n.Tr "settings.change_password"}}
6+
</h4>
7+
<div class="ui attached segment">
8+
<form class="ui form" action="{{.ChangePasscodeLink}}" method="post">
9+
{{.CsrfTokenHtml}}
10+
<div class="required inline field {{if and (.Err_Password) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeSignIn))}}error{{end}}">
11+
<label for="password">{{.i18n.Tr "password"}}</label>
12+
<input id="password" name="password" type="password" value="{{.password}}" autocomplete="off" required>
13+
</div>
14+
15+
16+
<div class="required inline field {{if and (.Err_Password) (or (not .LinkAccountMode) (and .LinkAccountMode .LinkAccountModeRegister))}}error{{end}}">
17+
<label for="retype">{{.i18n.Tr "re_type"}}</label>
18+
<input id="retype" name="retype" type="password" autocomplete="off" required>
19+
</div>
20+
21+
<div class="inline field">
22+
<label></label>
23+
<button class="ui green button">{{.i18n.Tr "settings.change_password" }}</button>
24+
</div>
25+
</form>
26+
</div>

0 commit comments

Comments
 (0)