cookies

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2017 License: MIT Imports: 13 Imported by: 0

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

Jump to

Keyboard shortcuts

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