This commit is contained in:
Sakurasan
2023-06-10 19:40:47 +08:00
parent bae47a43ad
commit bc39ce1ddd
2 changed files with 28 additions and 2 deletions

View File

@@ -73,6 +73,15 @@ func GetUserByName(name string) (*User, error) {
return &user, nil
}
func GetUserByToken(token string) (*User, error) {
var user User
result := db.Where("token = ?", token).First(&user)
if result.Error != nil {
return nil, result.Error
}
return &user, nil
}
func GetUserID(authkey string) (int, error) {
var user User
result := db.Where(&User{Token: authkey}).First(&user)