user

package
v0.0.0-...-91518e1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTClaims

type JWTClaims struct {
	ID string `bson:"_id" json:"id"`
	jwt.StandardClaims
}

JWTClaims is the user information embedded in the JWT. We add jwt.StandardClaims as an embedded type, to provide fields like expiry time

func ParseToken

func ParseToken(clock clockwork.Clock, tokenStr string, jwtKey string) (claims JWTClaims, err error)

ParseToken parses a JWT string to the claims struct.

type User

type User struct {
	ID       primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Name     string             `json:"name" bson:"name"`
	Lastname string             `json:"lastname" bson:"lastname"`
	Email    string             `json:"email" bson:"email"`

	// IDs in external authentication providers.
	GoogleID      string `json:"-" bson:"googleId"`
	GoogleToken   string `json:"-" bson:"googleToken"`
	FacebookID    string `json:"-" bson:"facebookId"`
	FacebookToken string `json:"-" bson:"facebookToken"`
}

User is the representation of an user in the system.

func Create

func Create(ctx context.Context, db database.Client, provider string, userInfo auth.ProviderUser) (*User, error)

Create adds a user record to the database.

func GetByProviderID

func GetByProviderID(ctx context.Context, db database.Client, provider, ID string) (*User, error)

GetByProviderID returns a user whose provider's ID matches the given one.

func (User) Token

func (u User) Token(clock clockwork.Clock, duration time.Duration, jwtKey string) (string, error)

Token returns the token for a user.

Jump to

Keyboard shortcuts

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