auth

package
v0.0.0-...-ff237a8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserKey key = iota
)

Variables

View Source
var (
	AccessTokenDuration  = time.Hour * 24 * 30  // Token valid for 1 month
	RefreshTokenDuration = time.Hour * 24 * 365 // Refresh token valid for 1 year
)

Functions

This section is empty.

Types

type Service

type Service struct {
	Repository *repo.Repository
}

func Init

func Init(repo *repo.Repository) *Service

func (*Service) CurrentUser

func (s *Service) CurrentUser(ctx context.Context) (*types.User, error)

func (*Service) GenerateToken

func (s *Service) GenerateToken(ctx context.Context, email string, duration time.Duration) (string, error)

func (*Service) Login

func (s *Service) Login(ctx context.Context, login types.LoginInput) (*types.JWT, error)

func (*Service) RefreshToken

func (s *Service) RefreshToken(ctx context.Context, data types.JWT) (*types.JWT, error)

func (*Service) SetCurrentUser

func (s *Service) SetCurrentUser(ctx context.Context, user *types.User) context.Context

func (*Service) Signup

func (s *Service) Signup(ctx context.Context, newUser types.User, password string) (*types.JWT, error)

func (*Service) ValidateToken

func (s *Service) ValidateToken(ctx context.Context, tokenStr string) (*types.Claims, error)

Jump to

Keyboard shortcuts

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