IsUserEnabled checks user status from Redis first, falls back to DB if needed func IsUserEnabled(id int, fromDB bool) (status bool, err error) { defer func() { // Update Redis cache asynchronously on successful DB read if shouldUpdateRedis(fromDB, err) { gopool.Go(func() { if err := upda
(token string)
| 554 | //} |
| 555 | |
| 556 | func ValidateAccessToken(token string) (user *User) { |
| 557 | if token == "" { |
| 558 | return nil |
| 559 | } |
| 560 | token = strings.Replace(token, "Bearer ", "", 1) |
| 561 | user = &User{} |
| 562 | if DB.Where("access_token = ?", token).First(user).RowsAffected == 1 { |
| 563 | return user |
| 564 | } |
| 565 | return nil |
| 566 | } |
| 567 | |
| 568 | // GetUserQuota gets quota from Redis first, falls back to DB if needed |
| 569 | func GetUserQuota(id int, fromDB bool) (quota int, err error) { |