Add context for everything

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-21 16:43:46 +08:00
parent 83df018d34
commit b8f89ab655
27 changed files with 309 additions and 127 deletions

View File

@@ -14,9 +14,7 @@ type Token struct {
Email string
}
func NewAuthCode(clientId string, email string) (string, error) {
ctx := context.Background()
func NewAuthCode(ctx context.Context, clientId string, email string) (string, error) {
// generate random code
b := make([]byte, 32)
if _, err := rand.Read(b); err != nil {
@@ -48,8 +46,7 @@ func NewAuthCode(clientId string, email string) (string, error) {
return code, nil
}
func VerifyAuthCode(code string) (*Token, bool) {
ctx := context.Background()
func VerifyAuthCode(ctx context.Context, code string) (*Token, bool) {
key := "auth_code:" + code
// Read auth code payload