token

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package token provides policy wrappers / getters for queries and mutations during password reset, signup

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIncorrectEmail   = errors.New("privacy token has incorrect email")
	ErrInvalidTokenType = errors.New("invalid token type")
)

Functions

func NewContextWithResetToken

func NewContextWithResetToken(parent context.Context, resetToken string) context.Context

NewContextWithResetToken returns a new context with the reset token inside

func NewContextWithSignUpToken

func NewContextWithSignUpToken(parent context.Context, email string) context.Context

NewContextWithSignUpToken creates a new context with a sign-up token. It takes a parent context and a sign-up token as parameters and returns a new context with the sign-up token added

func NewContextWithVerifyToken

func NewContextWithVerifyToken(parent context.Context, verifyToken string) context.Context

NewContextWithVerifyToken returns a new context with the verify token inside

Types

type PrivacyToken

type PrivacyToken interface {
	GetContextKey() interface{}
}

PrivacyToken interface

type ResetToken

type ResetToken struct {
	PrivacyToken
	// contains filtered or unexported fields
}

ResetToken that implements the PrivacyToken interface

func NewResetTokenWithToken

func NewResetTokenWithToken(token string) ResetToken

NewResetTokenWithToken creates a new PrivacyToken of type ResetToken with token set

func ResetTokenFromContext

func ResetTokenFromContext(ctx context.Context) *ResetToken

ResetTokenFromContext parses a context for a reset token and returns the token

func (ResetToken) GetContextKey

func (ResetToken) GetContextKey() interface{}

GetContextKey from ResetToken

func (*ResetToken) GetToken

func (token *ResetToken) GetToken() string

GetToken from reset token

func (*ResetToken) SetToken

func (token *ResetToken) SetToken(t string)

SetToken on the reset token

type SignUpToken

type SignUpToken struct {
	PrivacyToken
	// contains filtered or unexported fields
}

SignUpToken that implements the PrivacyToken interface

func EmailSignUpTokenFromContext

func EmailSignUpTokenFromContext(ctx context.Context) *SignUpToken

EmailSignUpTokenFromContext retrieves the value associated with the signUpTokenKey key from the context. It then type asserts the value to an EmailSignUpToken and returns it. If the value is not of type EmailSignUpToken, it returns nil

func NewSignUpTokenWithEmail

func NewSignUpTokenWithEmail(email string) SignUpToken

NewSignUpTokenWithEmail creates a new PrivacyToken of type SignUpToken with email set

func (SignUpToken) GetContextKey

func (SignUpToken) GetContextKey() interface{}

GetContextKey from SignUpToken

func (*SignUpToken) GetEmail

func (token *SignUpToken) GetEmail() string

GetEmail from sign-up token

func (*SignUpToken) SetEmail

func (token *SignUpToken) SetEmail(email string)

SetEmail on the sign-up token

type VerifyToken

type VerifyToken struct {
	PrivacyToken
	// contains filtered or unexported fields
}

VerifyToken that implements the PrivacyToken interface

func NewVerifyTokenWithToken

func NewVerifyTokenWithToken(token string) VerifyToken

NewVerifyTokenWithToken creates a new PrivacyToken of type SignUpToken with email set

func VerifyTokenFromContext

func VerifyTokenFromContext(ctx context.Context) *VerifyToken

VerifyTokenFromContext parses a context for a verify token and returns the token

func (VerifyToken) GetContextKey

func (VerifyToken) GetContextKey() interface{}

GetContextKey from VerifyToken

func (*VerifyToken) GetToken

func (token *VerifyToken) GetToken() string

GetToken from verify token

func (*VerifyToken) SetToken

func (token *VerifyToken) SetToken(t string)

SetToken on the verify token

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL