auth

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const USER_ID = "userId"

user id key

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Ses *sessions.Sessions
	JWT *jwt.JWTUtil
}

Auth is authentication management struct

func New

func New(ses *sessions.Sessions, jwt *jwt.JWTUtil) *Auth

New initiates new Auth

func Resolve

func Resolve() *Auth

Resolve returns the initiated Auth variable

func (*Auth) Check

func (a *Auth) Check(c *gin.Context) (bool, error)

Check checks if a user is logged in

func (*Auth) Login

func (a *Auth) Login(userId uint, c *gin.Context) error

Login logs the user in by id

func (*Auth) Logout

func (a *Auth) Logout(c *gin.Context) error

Logout logs the user out by id

func (*Auth) UserID added in v1.4.2

func (a *Auth) UserID(c *gin.Context) (uint, error)

UserID returns authenticated user id

Jump to

Keyboard shortcuts

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