Add error handling for token key generation
This commit is contained in:
parent
e2dda0ade7
commit
376edd7267
1 changed files with 4 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ package auth
|
|||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -14,6 +15,8 @@ type token struct {
|
|||
|
||||
func generateKey() string {
|
||||
key := [32]byte{}
|
||||
rand.Read(key[:])
|
||||
if _, err := rand.Read(key[:]); err != nil {
|
||||
log.Fatal("can't generate a vaild key", err)
|
||||
}
|
||||
return base64.StdEncoding.EncodeToString(key[:])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue