mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 14:06:36 +08:00
chore: remove accidental test upload
fix(user): backfill snowflake id on login for legacy zero user
This commit is contained in:
@@ -5,6 +5,7 @@ package user
|
||||
|
||||
import (
|
||||
"Wavelet/core/contracts"
|
||||
"Wavelet/pkg/idgen"
|
||||
"Wavelet/pkg/logger"
|
||||
"Wavelet/pkg/response"
|
||||
"context"
|
||||
@@ -107,6 +108,13 @@ func Login(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if user.ID == 0 {
|
||||
newID := idgen.NextUint64ID()
|
||||
if err := getDB(c.Request.Context()).Model(&User{}).Where("username = ?", user.Username).Update("id", newID).Error; err == nil {
|
||||
user.ID = newID
|
||||
}
|
||||
}
|
||||
|
||||
sess := sessions.Default(c)
|
||||
sess.Set(contracts.AuthUserIDKey, strconv.FormatUint(user.ID, 10))
|
||||
sess.Set(contracts.AuthUserNameKey, user.Username)
|
||||
|
||||
Reference in New Issue
Block a user