Files
authorizer/server/token/verification_token.go

24 lines
655 B
Go
Raw Normal View History

package token
2021-07-12 23:52:16 +05:30
import (
"time"
2021-07-23 21:57:44 +05:30
"github.com/authorizerdev/authorizer/server/constants"
2022-01-17 11:32:13 +05:30
"github.com/authorizerdev/authorizer/server/envstore"
2021-07-12 23:52:16 +05:30
"github.com/golang-jwt/jwt"
)
2022-01-17 11:32:13 +05:30
// CreateVerificationToken creates a verification JWT token
2022-01-31 11:35:24 +05:30
func CreateVerificationToken(email, tokenType, hostname string) (string, error) {
2022-02-12 15:54:23 +05:30
claims := jwt.MapClaims{
"exp": time.Now().Add(time.Minute * 30).Unix(),
"iat": time.Now().Unix(),
"token_type": tokenType,
"email": email,
"host": hostname,
"redirect_url": envstore.EnvInMemoryStoreObj.GetStringStoreEnvVariable(constants.EnvKeyAppURL),
2021-07-12 23:52:16 +05:30
}
2022-02-12 15:54:23 +05:30
return SignJWTToken(claims)
2021-07-12 23:52:16 +05:30
}