Add and fix errname
This commit is contained in:
parent
0c45f8d252
commit
0c005a6b01
10 changed files with 50 additions and 51 deletions
|
@ -13,8 +13,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
errorAuthKeyNotFound = Error("AuthKey not found")
|
||||
errorAuthKeyExpired = Error("AuthKey expired")
|
||||
errPreAuthKeyNotFound = Error("AuthKey not found")
|
||||
errPreAuthKeyExpired = Error("AuthKey expired")
|
||||
errSingleUseAuthKeyHasBeenUsed = Error("AuthKey has already been used")
|
||||
)
|
||||
|
||||
|
@ -120,11 +120,11 @@ func (h *Headscale) checkKeyValidity(k string) (*PreAuthKey, error) {
|
|||
result.Error,
|
||||
gorm.ErrRecordNotFound,
|
||||
) {
|
||||
return nil, errorAuthKeyNotFound
|
||||
return nil, errPreAuthKeyNotFound
|
||||
}
|
||||
|
||||
if pak.Expiration != nil && pak.Expiration.Before(time.Now()) {
|
||||
return nil, errorAuthKeyExpired
|
||||
return nil, errPreAuthKeyExpired
|
||||
}
|
||||
|
||||
if pak.Reusable || pak.Ephemeral { // we don't need to check if has been used before
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue