Documentation

Index

Constants

View Source
const (
	// CookieName : Name of cookie
	CookieName = "session"

	// UserContextKey : key for user context
	UserContextKey = "nyaapantsu.user"
)

Variables

This section is empty.

Functions

func Clear

func Clear(c *gin.Context)

Clear : Erase cookie session

func CreateUserAuthentication

func CreateUserAuthentication(c *gin.Context, form *userValidator.LoginForm) (*models.User, int, error)

CreateUserAuthentication creates user authentication.

func CurrentUser

func CurrentUser(c *gin.Context) (*models.User, int, error)

CurrentUser retrieves a current user.

func Decode

func Decode(cookieValue string) (uint, error)

Decode : Encoding & Decoding of the cookie value

func Encode

func Encode(userID uint, validUntil time.Time) (string, error)

Encode : Encoding of the cookie value

func RetrieveUserFromRequest

func RetrieveUserFromRequest(c *gin.Context, id uint) (*models.User, bool, uint, int, error)

RetrieveUser retrieves a user.

func SetLogin

func SetLogin(c *gin.Context, user *models.User) (int, error)

SetLogin sets the authentication cookie

Types

type CurrentUserRetriever

type CurrentUserRetriever struct{}

CurrentUserRetriever struct for languages

func NewCurrentUserRetriever

func NewCurrentUserRetriever() *CurrentUserRetriever

NewCurrentUserRetriever create CurrentUserRetriever Struct for languages

func (*CurrentUserRetriever) RetrieveCurrentUser

func (*CurrentUserRetriever) RetrieveCurrentUser(c *gin.Context) (*models.User, error)

RetrieveCurrentUser retrieve current user for languages

Source Files