mirror of
https://github.com/boringproxy/boringproxy.git
synced 2024-07-04 11:22:57 -05:00
34 lines
496 B
Go
34 lines
496 B
Go
package boringproxy
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
type Auth struct {
|
|
db *Database
|
|
pendingRequests map[string]*LoginRequest
|
|
mutex *sync.Mutex
|
|
}
|
|
|
|
type LoginRequest struct {
|
|
Email string
|
|
}
|
|
|
|
func NewAuth(db *Database) *Auth {
|
|
|
|
pendingRequests := make(map[string]*LoginRequest)
|
|
mutex := &sync.Mutex{}
|
|
|
|
return &Auth{db, pendingRequests, mutex}
|
|
}
|
|
|
|
func (a *Auth) Authorized(token string) bool {
|
|
_, exists := a.db.GetTokenData(token)
|
|
|
|
if exists {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|