diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2024-02-04 15:05:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-04 14:05:26 +0000 |
commit | 688d4a1f719d2df4d2626453f4bc042c1874a375 (patch) | |
tree | 961a5bfa37fa4814bd636119f5dd3fe2c877ac3f /models | |
parent | f8b471ace1b59bd3fc3a04c9ddb5f62dd1dd5396 (diff) | |
download | gitea-688d4a1f719d2df4d2626453f4bc042c1874a375.tar.gz gitea-688d4a1f719d2df4d2626453f4bc042c1874a375.zip |
Unify password changing and invalidate auth tokens (#27625)
- Unify the password changing code
- Invalidate existing auth tokens when changing passwords
Diffstat (limited to 'models')
-rw-r--r-- | models/auth/auth_token.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/models/auth/auth_token.go b/models/auth/auth_token.go index 65f1b169eb..81f07d1a83 100644 --- a/models/auth/auth_token.go +++ b/models/auth/auth_token.go @@ -54,6 +54,11 @@ func DeleteAuthTokenByID(ctx context.Context, id string) error { 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 { _, err := db.GetEngine(ctx).Where(builder.Lt{"expires_unix": timeutil.TimeStampNow()}).Delete(&AuthToken{}) return err |