summaryrefslogtreecommitdiffstats
path: root/models/login_source.go
diff options
context:
space:
mode:
authorEpicCoder <EpicCoder@users.noreply.github.com>2019-07-07 08:01:01 +0200
committertechknowlogick <techknowlogick@gitea.io>2019-07-07 02:01:01 -0400
commit8d9d6aa903baf3662fa31bceb489291564a873d1 (patch)
tree7a952e1c0fce29af1de19df54fa570e24ff09fcc /models/login_source.go
parent1b85b248e42a9d45d4dc278d399ddab3edcedfdb (diff)
downloadgitea-8d9d6aa903baf3662fa31bceb489291564a873d1.tar.gz
gitea-8d9d6aa903baf3662fa31bceb489291564a873d1.zip
Add additional password hash algorithms (closes #5859) (#6023)
Diffstat (limited to 'models/login_source.go')
-rw-r--r--models/login_source.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/models/login_source.go b/models/login_source.go
index 626c232772..26544588c1 100644
--- a/models/login_source.go
+++ b/models/login_source.go
@@ -22,6 +22,7 @@ import (
"code.gitea.io/gitea/modules/auth/oauth2"
"code.gitea.io/gitea/modules/auth/pam"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
)
@@ -665,6 +666,15 @@ func UserSignIn(username, password string) (*User, error) {
switch user.LoginType {
case LoginNoType, LoginPlain, LoginOAuth2:
if user.IsPasswordSet() && user.ValidatePassword(password) {
+
+ // Update password hash if server password hash algorithm have changed
+ if user.PasswdHashAlgo != setting.PasswordHashAlgo {
+ user.HashPassword(password)
+ if err := UpdateUserCols(user, "passwd", "passwd_hash_algo"); err != nil {
+ return nil, err
+ }
+ }
+
// WARN: DON'T check user.IsActive, that will be checked on reqSign so that
// user could be hint to resend confirm email.
if user.ProhibitLogin {