1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-06-15 00:15:15 +02:00

completed API from signup to auth token with swagger UI.

This commit is contained in:
Lee Brown
2019-06-25 06:25:55 -08:00
parent 2fbda74a73
commit 8328cf525b
15 changed files with 443 additions and 26 deletions

View File

@ -219,12 +219,22 @@ func generateToken(ctx context.Context, dbConn *sqlx.DB, tknGen TokenGenerator,
claims = auth.NewClaims(userID, accountID, accountIds, account.Roles, now, expires)
// Generate a token for the user with the defined claims.
tkn, err := tknGen.GenerateToken(claims)
tknStr, err := tknGen.GenerateToken(claims)
if err != nil {
return Token{}, errors.Wrap(err, "generating token")
}
return Token{Token: tkn, claims: claims}, nil
tkn := Token{
AccessToken: tknStr,
TokenType: "Bearer",
claims: claims,
}
if expires.Seconds() > 0 {
tkn.Expiry = now.Add(expires)
}
return tkn, nil
}
// mockTokenGenerator is used for testing that Authenticate calls its provided