Documentation ¶
Index ¶
- Constants
- func Authorize() gin.HandlerFunc
- func AuthorizedUser(c *gin.Context) (user db.User, err error)
- func AuthorizedUserIsAdmin() gin.HandlerFunc
- func ChangePassword(c *gin.Context)
- func ConfirmOTP(c *gin.Context)
- func DBConnOrAbort(c *gin.Context) *gorm.DB
- func DBConnection() gin.HandlerFunc
- func DeleteUser(c *gin.Context)
- func GenerateOTP(c *gin.Context)
- func LogFormat() gin.HandlerFunc
- func New() http.Handler
- func Page(c *gin.Context) (int, error)
- func PageSize(c *gin.Context) (int, error)
- func RenewSession(c *gin.Context)
- func RequestID() gin.HandlerFunc
- func RequesterIsAuthorizedUser() gin.HandlerFunc
- func ResetOTP(c *gin.Context)
- func SendResetPasswordEmail(c *gin.Context)
- func SendVerificationEmail(c *gin.Context)
- func Signin(c *gin.Context)
- func Signup(c *gin.Context)
- func User(c *gin.Context)
- func Users(c *gin.Context)
- func VerifySignupToken(c *gin.Context)
- type ChangePasswordParam
- type ConfirmOTPParam
- type ErrorCodeResponse
- type Link
- type ResetOTPParam
- type ResetPasswordEmailData
- type ResetPasswordEmailResponseForTest
- type SendEmailParam
- type SiginResponse
- type SigninParam
- type SignupParam
- type UsersResponse
- type VerificationEmailData
- type VerificationEmailResponseForTest
Constants ¶
View Source
const ( ErrorCodeUnknown = iota + 1000 ErrorCodeDBEnv ErrorCodeDBConn ErrorCodeNoDBConn ErrorCodeWrongDBConn ErrorCodeDBTransaction ErrorCodeSignJWT ErrorCodeParseJWT ErrorCodeSendEmail ErrorCodeTmplExecute ErrorCodeTmplParse )
Internal server error codes.
View Source
const ( ErrorCodeBindJSON = iota + 2000 ErrorCodeBadPage ErrorCodeBadPageSize ErrorCodeExpiredToken ErrorCodeInvalidPassword )
Parameter error codes.
View Source
const ( ErrorCodeNotFoundUser = iota + 3000 ErrorCodeUserAlreadyExists ErrorCodeIncorrectPassword ErrorCodeSetPassword ErrorCodeOTPAlreadyRegistered ErrorCodeNoOTPSecretKey ErrorCodeIncorrectOTP ErrorCodeNoOTPBackupCodes ErrorCodeRequireVerifyOTP ErrorCodeOTPProvisioningURI ErrorCodeSetOTPBackupCodes ErrorCodeOTPNotRegistered )
User data error codes.
View Source
const (
ErrorCodeAuthorizedUser = iota + 4000
)
Authorized User error codes.
Variables ¶
This section is empty.
Functions ¶
func AuthorizedUser ¶
AuthorizedUser .
func RequesterIsAuthorizedUser ¶
func RequesterIsAuthorizedUser() gin.HandlerFunc
RequesterIsAuthorizedUser .
Types ¶
type ChangePasswordParam ¶
type ChangePasswordParam struct { CurrentPassword string `json:"current_password" binding:"required"` Password string `json:"password" binding:"required"` }
ChangePasswordParam .
type ConfirmOTPParam ¶
type ConfirmOTPParam struct {
OTP string `json:"otp" binding:"required,numeric"`
}
ConfirmOTPParam .
type ErrorCodeResponse ¶
type ErrorCodeResponse struct { ErrorCode int `json:"error_code"` ErrorMessage string `json:"error_message"` Links []Link `json:"links"` }
ErrorCodeResponse .
func NewErrResWithErr ¶
func NewErrResWithErr(code int, err error) ErrorCodeResponse
NewErrResWithErr .
func NewErrResWithLinks ¶
func NewErrResWithLinks(code int, links []Link) ErrorCodeResponse
NewErrResWithLinks .
type Link ¶
type Link struct { Rel string `json:"rel"` Method string `json:"method"` Href string `json:"href"` }
Link .
type ResetOTPParam ¶
type ResetOTPParam struct {
BackupCode string `json:"backup_code" binding:"required,numeric"`
}
ResetOTPParam .
type ResetPasswordEmailData ¶
type ResetPasswordEmailData struct { UserEmail string `json:"user_email"` ResetURL string `json:"reset_url"` ExpireMin int `json:"expire_min"` Organization string `json:"organization"` }
ResetPasswordEmailData .
type ResetPasswordEmailResponseForTest ¶
type ResetPasswordEmailResponseForTest struct { ResetPasswordEmailData ResetPasswordToekn string `json:"reset_password_token"` Subject string `json:"subject"` Body string `json:"body"` }
ResetPasswordEmailResponseForTest .
type SendEmailParam ¶
type SendEmailParam struct { Email string `json:"email" binding:"required,email"` Subject string `json:"subject" binding:"required"` Body string `json:"body" binding:"required"` }
SendEmailParam .
type SiginResponse ¶
SiginResponse .
type SigninParam ¶
type SigninParam struct { Email string `json:"email" binding:"required"` Password string `json:"password" binding:"required"` OTP string `json:"otp"` }
SigninParam .
type SignupParam ¶
type SignupParam struct { Token string `json:"token" binding:"required"` Password string `json:"password" binding:"required"` }
SignupParam .
type UsersResponse ¶
type UsersResponse struct { Page int `json:"page"` PageSize int `json:"page_size"` HasNext bool `json:"has_next"` Users []db.User `json:"users"` Links []Link `json:"links"` }
UsersResponse .
func (*UsersResponse) AttachLinks ¶
func (r *UsersResponse) AttachLinks(page, pageSize int, emails []string)
AttachLinks .
type VerificationEmailData ¶
type VerificationEmailData struct { UserEmail string `json:"user_email"` SignupURL string `json:"signup_url"` ExpireMin int `json:"expire_min"` Organization string `json:"organization"` }
VerificationEmailData .
type VerificationEmailResponseForTest ¶
type VerificationEmailResponseForTest struct { VerificationEmailData SignupToken string `json:"signup_token"` Subject string `json:"subject"` Body string `json:"body"` }
VerificationEmailResponseForTest .
Click to show internal directories.
Click to hide internal directories.