auth

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearRefreshInContext

func ClearRefreshInContext(c *gin.Context)

func Login

func Login(c *gin.Context)

Login godoc

@Summary	User login
@Schemes
@Tags		Auth
@Accept		json
@Produce	json
@Success	200		{object}	AuthResponse
@Failure	400		{object}	utils.CommonError
@Failure	422		{object}	utils.CommonValidationError
@Param		request	body		LoginValidator	true	"Request Body"
@Router		/auth/login [post]

func Logout

func Logout(c *gin.Context)

Logout godoc

@Summary	Logout (clear refresh token from cookies)
@Schemes
@Tags		Auth
@Accept		json
@Produce	json
@Success	204		"Empty response"
@Param		cookie	header	string	false	"Required Cookie"	default(refresh_token="...")
@Router		/auth/logout [delete]

func Refresh

func Refresh(c *gin.Context)

Refresh godoc

@Summary	Refresh token pair
@Schemes
@Tags		Auth
@Accept		json
@Produce	json
@Success	200		{object}	AuthResponse
@Failure	401		{object}	utils.CommonError
@Param		cookie	header		string	true	"Cookie"	default(refresh_token="...")
@Router		/auth/refresh [get]

func Registration

func Registration(c *gin.Context)

Registration godoc

@Summary	User registration
@Schemes
@Tags		Auth
@Accept		json
@Produce	json
@Success	200		{object}	AuthResponse
@Failure	422		{object}	utils.CommonValidationError
@Param		request	body		RegisterValidator	true	"Request Body"
@Router		/auth/registration [post]

func Router

func Router(route *gin.RouterGroup)

func SetRefreshToContext

func SetRefreshToContext(c *gin.Context, refreshToken string) error

Types

type AuthResponse

type AuthResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type AuthSerializer

type AuthSerializer struct {
	C *gin.Context
}

func (*AuthSerializer) Response

func (self *AuthSerializer) Response() AuthResponse

type LoginValidator

type LoginValidator struct {
	Email    string `json:"email" binding:"required,email"`
	Password string `json:"password" binding:"required"`
}

func NewLoginValidator

func NewLoginValidator() LoginValidator

func (*LoginValidator) Bind

func (v *LoginValidator) Bind(c *gin.Context) error

type RefreshValidator added in v0.7.2

type RefreshValidator struct {
	Token string `json:"token" binding:""`
}

func NewRefreshValidator added in v0.7.2

func NewRefreshValidator() RefreshValidator

func (*RefreshValidator) Bind added in v0.7.2

func (v *RefreshValidator) Bind(c *gin.Context) error

type RegisterValidator

type RegisterValidator struct {
	Email     string           `json:"email" binding:"required,email"`
	Password  string           `json:"password" binding:"required,min=8,max=64"`
	UserModel models.UserModel `json:"-"`
}

func NewRegisterValidator

func NewRegisterValidator() RegisterValidator

func (*RegisterValidator) Bind

func (v *RegisterValidator) Bind(c *gin.Context) error

Jump to

Keyboard shortcuts

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