user

package
v0.0.0-...-a4ecc4f Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SlugUsernameEmpty   = "empty_username"
	SlugPasswordEmpty   = "empty_password"
	SlugInvalidUsername = "invalid_username"
	SlugInvalidPassword = "invalid_username"
)
View Source
const (
	SlugInvalidPasswordLength    = "invalid_password_length"
	SlugInvalidPasswordNoLetters = "invalid_password_no_letters"
	SlugInvalidPasswordNoNumbers = "invalid_password_no_numbers"
	SlugInvalidPasswordNoSpecial = "invalid_password_no_specials"
)
View Source
const (
	SlugUserAlreadyExists = "user_already_exists"
	SlugDoesNotUserExist  = "user_does_not_exist"
	SlugWrongPassword     = "wrong_password"
)
View Source
const (
	CookieSessionKey = "session"
)
View Source
const UsernameHeaderKey = "x-username"

Variables

This section is empty.

Functions

func RemoveSession

func RemoveSession(c *gin.Context, redis *redis.Redis, cookieValue string) error

func SetSession

func SetSession(c *gin.Context, redis *redis.Redis, username string) error

func ValidatePassword

func ValidatePassword(s string) string

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(db repository.Storage, redis *redis.Redis) *Controller

func (*Controller) DeleteLogout

func (i *Controller) DeleteLogout(c *gin.Context) (*DeleteLogoutResp, *apihttp.Error)

func (*Controller) GetMe

func (i *Controller) GetMe(c *gin.Context) (*GetMeResp, *apihttp.Error)

func (*Controller) PostLogin

func (i *Controller) PostLogin(c *gin.Context, req PostLoginReq) (*PostLoginResp, *apihttp.Error)

func (*Controller) PostRegister

func (i *Controller) PostRegister(c *gin.Context, req PostRegisterReq) (*PostRegisterResp, *apihttp.Error)

type DeleteLogoutResp

type DeleteLogoutResp struct {
	Message string `json:"message"`
}

User Logout

type GetMeResp

type GetMeResp struct {
	Username string `json:"username"`
}

User Me

type PostLoginReq

type PostLoginReq struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

User Login

type PostLoginResp

type PostLoginResp struct {
	Username string `json:"username"`
}

User Login

type PostRegisterReq

type PostRegisterReq struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

User Register

func (*PostRegisterReq) Validate

func (p *PostRegisterReq) Validate() *apihttp.Error

TODO: add unit test

type PostRegisterResp

type PostRegisterResp struct {
	Username string `json:"username"`
}

User Register

type SessionData

type SessionData struct {
	Username  string    `json:"username"`
	ExpiresAt time.Time `json:"expires_at"`
}

User Session

Jump to

Keyboard shortcuts

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