Documentation ¶
Index ¶
- Constants
- func RemoveSession(c *gin.Context, redis *redis.Redis, cookieValue string) error
- func SetSession(c *gin.Context, redis *redis.Redis, username string) error
- func ValidatePassword(s string) string
- type Controller
- func (i *Controller) DeleteLogout(c *gin.Context) (*DeleteLogoutResp, *apihttp.Error)
- func (i *Controller) GetMe(c *gin.Context) (*GetMeResp, *apihttp.Error)
- func (i *Controller) PostLogin(c *gin.Context, req PostLoginReq) (*PostLoginResp, *apihttp.Error)
- func (i *Controller) PostRegister(c *gin.Context, req PostRegisterReq) (*PostRegisterResp, *apihttp.Error)
- type DeleteLogoutResp
- type GetMeResp
- type PostLoginReq
- type PostLoginResp
- type PostRegisterReq
- type PostRegisterResp
- type SessionData
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 ValidatePassword ¶
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) 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 PostLoginReq ¶
User Login
type PostRegisterReq ¶
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
Click to show internal directories.
Click to hide internal directories.