Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force user to change password #4489

Merged
merged 39 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0bef325
redirect to login page after successfully activating account
adelowo Jul 15, 2018
68d57a1
Merge remote-tracking branch 'origin' into force_user_password_change…
adelowo Jul 21, 2018
23acb29
force users to change password if account was created by an admin
adelowo Jul 21, 2018
ff42bfd
force users to change password if account was created by an admin
adelowo Jul 21, 2018
26fccdf
fixed build
adelowo Jul 21, 2018
4562460
fixed build
adelowo Jul 21, 2018
5a2ea86
fix pending issues with translation and wrong routes
adelowo Jul 21, 2018
3b87fef
make sure path check is safe
adelowo Jul 21, 2018
7e67ecc
remove unneccessary newline
adelowo Jul 21, 2018
59432fa
make sure users that don't have to view the form get redirected
adelowo Jul 21, 2018
741ef66
move route to use /settings prefix so as to make sure unauthenticated…
adelowo Jul 21, 2018
9b4f70f
update as per @lafriks review
adelowo Jul 21, 2018
845c00b
add necessary comment
adelowo Jul 21, 2018
3b7258e
Merge branch 'master' into force_user_to_change_password
lafriks Jul 22, 2018
b6b39d3
remove unrelated changes
adelowo Jul 22, 2018
4ebdfc1
Merge branch 'force_user_to_change_password' of github.com:adelowo/gi…
adelowo Jul 22, 2018
e0f8fd8
support redirecting to location the user actually want to go to befor…
adelowo Jul 23, 2018
3e5ed18
Merge branch 'master' into force_user_to_change_password
adelowo Jul 27, 2018
1a75475
Fix merge connflicts
adelowo Jul 28, 2018
4402c56
Merge branch 'master' of https://github.com/go-gitea/gitea into force…
adelowo Jul 28, 2018
f7e1e08
run make fmt
adelowo Jul 28, 2018
4d96ba5
added tests
adelowo Jul 30, 2018
95f035d
improve assertions
adelowo Jul 30, 2018
8ea7cdc
add assertion
adelowo Jul 30, 2018
0181ebf
fix copyright year
adelowo Aug 1, 2018
d083410
Merge branch 'master' into force_user_to_change_password
adelowo Aug 1, 2018
d3febca
Merge branch 'master' of https://github.com/go-gitea/gitea into force…
adelowo Aug 6, 2018
dafa9c8
Merge branch 'master' into force_user_to_change_password
adelowo Aug 10, 2018
8c6e9c6
Merge branch 'master' into force_user_to_change_password
adelowo Aug 14, 2018
454cd3a
Merge branch 'master' into force_user_to_change_password
adelowo Aug 16, 2018
d7ee5f8
Merge branch 'master' into force_user_to_change_password
adelowo Aug 21, 2018
5441645
Merge branch 'master' into force_user_to_change_password
adelowo Aug 21, 2018
98933c6
Merge branch 'master' into force_user_to_change_password
adelowo Aug 23, 2018
d2ddc69
Merge branch 'master' into force_user_to_change_password
adelowo Aug 24, 2018
4c6658a
Merge branch 'master' into force_user_to_change_password
adelowo Aug 30, 2018
e2ef29b
Merge branch 'master' into force_user_to_change_password
adelowo Sep 4, 2018
16b5b61
Merge branch 'master' into force_user_to_change_password
techknowlogick Sep 5, 2018
a4152f2
Merge branch 'master' into force_user_to_change_password
adelowo Sep 10, 2018
a03c9a3
Merge branch 'master' into force_user_to_change_password
lafriks Sep 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions routers/admin/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2018

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh snap... fixed

// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package admin

import (
"path/filepath"
"testing"

"code.gitea.io/gitea/models"
)

func TestMain(m *testing.M) {
models.MainTest(m, filepath.Join("..", ".."))
}
49 changes: 49 additions & 0 deletions routers/admin/users_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2017 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 admin

import (
"testing"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth"
"code.gitea.io/gitea/modules/test"
"github.com/stretchr/testify/assert"
)

func TestNewUserPost_MustChangePassword(t *testing.T) {

models.PrepareTestEnv(t)
ctx := test.MockContext(t, "admin/users/new")

u := models.AssertExistsAndLoadBean(t, &models.User{
IsAdmin: true,
ID: 2,
}).(*models.User)

ctx.User = u

username := "gitea"
email := "[email protected]"

form := auth.AdminCreateUserForm{
LoginType: "local",
LoginName: "local",
UserName: username,
Email: email,
Password: "xxxxxxxx",
SendNotify: false,
}

NewUserPost(ctx, form)

assert.NotEmpty(t, ctx.Flash.SuccessMsg)

u, err := models.GetUserByName(username)

assert.NoError(t, err)
assert.Equal(t, username, u.Name)
assert.Equal(t, email, u.Email)
}