mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 06:43:34 +01:00
Revert "Unify password changing and invalidate auth tokens (#27625)"
This reverts commit 688d4a1f71
.
This commit is contained in:
parent
80cf92bf1f
commit
1951c51c8e
3 changed files with 1 additions and 20 deletions
|
@ -54,11 +54,6 @@ func DeleteAuthTokenByID(ctx context.Context, id string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteAuthTokensByUserID(ctx context.Context, uid int64) error {
|
|
||||||
_, err := db.GetEngine(ctx).Where(builder.Eq{"user_id": uid}).Delete(&AuthToken{})
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteExpiredAuthTokens(ctx context.Context) error {
|
func DeleteExpiredAuthTokens(ctx context.Context) error {
|
||||||
_, err := db.GetEngine(ctx).Where(builder.Lt{"expires_unix": timeutil.TimeStampNow()}).Delete(&AuthToken{})
|
_, err := db.GetEngine(ctx).Where(builder.Lt{"expires_unix": timeutil.TimeStampNow()}).Delete(&AuthToken{})
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -187,10 +187,6 @@ func deleteUser(ctx context.Context, u *user_model.User, purge bool) (err error)
|
||||||
}
|
}
|
||||||
// ***** END: ExternalLoginUser *****
|
// ***** END: ExternalLoginUser *****
|
||||||
|
|
||||||
if err := auth_model.DeleteAuthTokensByUserID(ctx, u.ID); err != nil {
|
|
||||||
return fmt.Errorf("DeleteAuthTokensByUserID: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err = db.DeleteByID[user_model.User](ctx, u.ID); err != nil {
|
if _, err = db.DeleteByID[user_model.User](ctx, u.ID); err != nil {
|
||||||
return fmt.Errorf("delete: %w", err)
|
return fmt.Errorf("delete: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,6 @@ func UpdateAuth(ctx context.Context, u *user_model.User, opts *UpdateAuthOptions
|
||||||
u.LoginName = opts.LoginName.Value()
|
u.LoginName = opts.LoginName.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAuthTokens := false
|
|
||||||
if opts.Password.Has() && (u.IsLocal() || u.IsOAuth2()) {
|
if opts.Password.Has() && (u.IsLocal() || u.IsOAuth2()) {
|
||||||
password := opts.Password.Value()
|
password := opts.Password.Value()
|
||||||
|
|
||||||
|
@ -200,8 +199,6 @@ func UpdateAuth(ctx context.Context, u *user_model.User, opts *UpdateAuthOptions
|
||||||
if err := u.SetPassword(password); err != nil {
|
if err := u.SetPassword(password); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAuthTokens = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.MustChangePassword.Has() {
|
if opts.MustChangePassword.Has() {
|
||||||
|
@ -211,12 +208,5 @@ func UpdateAuth(ctx context.Context, u *user_model.User, opts *UpdateAuthOptions
|
||||||
u.ProhibitLogin = opts.ProhibitLogin.Value()
|
u.ProhibitLogin = opts.ProhibitLogin.Value()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := user_model.UpdateUserCols(ctx, u, "login_type", "login_source", "login_name", "passwd", "passwd_hash_algo", "salt", "must_change_password", "prohibit_login"); err != nil {
|
return user_model.UpdateUserCols(ctx, u, "login_type", "login_source", "login_name", "passwd", "passwd_hash_algo", "salt", "must_change_password", "prohibit_login")
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if deleteAuthTokens {
|
|
||||||
return auth_model.DeleteAuthTokensByUserID(ctx, u.ID)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue