mc-tgbot/services/mc/auth.go
2023-12-06 21:40:12 +08:00

54 lines
1020 B
Go

package mc
// import (
// "sync"
// "tg-mc/models"
// "time"
// )
// type Auth interface {
// IsAuthed(u models.User, expireMode bool) bool
// Auth(u models.User)
// Reject(u models.User)
// }
// type Authcator struct {
// UserMap *sync.Map
// }
// var authcator *Authcator
// func GetAuthcator() Auth {
// if authcator == nil {
// authcator = &Authcator{
// UserMap: &sync.Map{},
// }
// }
// return authcator
// }
// func (a *Authcator) IsAuthed(u models.User, expireMode bool) bool {
// return true
// // if u.MCName != "VaalaCat" {
// // return true
// // }
// if approveTime, ok := a.UserMap.Load(u.MCName); ok {
// if !expireMode {
// return true
// } else if time.Since(approveTime.(time.Time)) < 30*time.Second {
// return true
// } else {
// return false
// }
// }
// return false
// }
// func (a *Authcator) Auth(u models.User) {
// a.UserMap.Store(u.MCName, time.Now())
// }
// func (a *Authcator) Reject(u models.User) {
// a.UserMap.Delete(u.MCName)
// }