auth

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTokensAndSetCookies

func GenerateTokensAndSetCookies(user *user.User, c echo.Context) error

GenerateTokensAndSetCookies generates jwt token and saves it to the http-only cookie.

func GetJWTRefreshSecret

func GetJWTRefreshSecret() string

func GetJWTSecret

func GetJWTSecret() string

func GetUserMiddleware

func GetUserMiddleware(next echo.HandlerFunc) echo.HandlerFunc

func JWTErrorChecker

func JWTErrorChecker(err error, c echo.Context) error

JWTErrorChecker will be executed when user try to access a protected path.

func UserRoleMiddleware

func UserRoleMiddleware(role utils.Role) echo.MiddlewareFunc

Types

type ChangePassword

type ChangePassword struct {
	OldPassword string `json:"old_password"`
	NewPassword string `json:"new_password"`
}

type Claims

type Claims struct {
	UserID   uuid.UUID  `json:"user_id"`
	Username string     `json:"username"`
	Role     utils.Role `json:"role"`
	jwt.RegisteredClaims
}

func GetUserClaims

func GetUserClaims(c echo.Context) *Claims

GetUserClaims - returns user's claims

type CustomContext

type CustomContext struct {
	echo.Context
	UserClaims *Claims
}

type Service

type Service struct {
	Store *database.Database
}

func NewService

func NewService(store *database.Database) *Service

func (*Service) ChangePassword

func (s *Service) ChangePassword(c *CustomContext, passwordDto ChangePassword) error

func (*Service) Login

func (s *Service) Login(c echo.Context, uDto user.User) (*ent.User, error)

func (*Service) Me

func (s *Service) Me(c echo.Context, accessToken string) (*ent.User, error)

func (*Service) Refresh

func (s *Service) Refresh(c echo.Context, refreshToken string) error

func (*Service) Register

func (s *Service) Register(c echo.Context, user user.User) (*ent.User, error)

Jump to

Keyboard shortcuts

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