Documentation
¶
Overview ¶
Package authgrp provides handlers for user registration and signin
Index ¶
- func NewUserResponse(user db_generated.User) userResponse
- type Handler
- func (h *Handler) Register(app *web.App)
- func (h *Handler) SendEmail(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func (h *Handler) Signin(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func (h *Handler) Signup(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func (h *Handler) VerifyEmail(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- type SendEmailRequest
- type SendEmailResponse
- type SigninRequest
- type SigninResponse
- type SignupRequest
- type SignupResponse
- type VerifyEmailRequest
- type VerifyEmailResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewUserResponse ¶
func NewUserResponse(user db_generated.User) userResponse
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) SendEmail ¶
SendEmail godoc
@Summary Send an email to user with given subject @Description Send an email to user with given subject, currently subject=welcome, subject=verify and subject=report are implemented. User needs to have a non-null email to be verified, and have a verified email to receive emails of other subjects. @Tags Authentication @Accept json @Produce json @Security Bearer @Param request body SendEmailRequest true "Email subject" @Success 201 @Failure 400 @Failure 404 @Failure 409 @Router /send-email [post]
func (*Handler) Signin ¶
Signin godoc
@Summary Signin @Description Signin with username and password @Tags Authentication @Accept json @Produce json @Param body body SigninRequest true "request body" @Success 200 {object} SigninResponse @Failure 400 @Failure 409 @Router /signin [post]
func (*Handler) Signup ¶
Signup godoc
@Summary Signup @Description Signup with username, email (optional) and password. @Tags Authentication @Accept json @Produce json @Param body body SignupRequest true "request body" @Success 201 {object} SignupResponse @Failure 400 @Failure 409 @Router /signup [post]
func (*Handler) VerifyEmail ¶
VerifyEmail godoc
@Summary Verify email @Description Verify email with the id and code @Tags Authentication @Accept json @Produce json @Security Bearer @Param body body VerifyEmailRequest true "request body" @Success 200 {object} VerifyEmailResponse @Failure 400 @Failure 404 @Router /verify-email [post]
type SendEmailRequest ¶
type SendEmailRequest struct {
Subject string `json:"subject" validate:"required"`
}
type SendEmailResponse ¶
type SendEmailResponse struct {
TaskId string `json:"task_id"`
}
type SigninRequest ¶
type SigninResponse ¶
type SigninResponse struct { User userResponse `json:"user"` AccessToken string `json:"access_token"` }
type SignupRequest ¶
type SignupRequest struct { // 3 to 20 characters, only letters and numbers Username string `json:"username" validate:"required,alphanum,username"` // Email address (Optional) Email string `json:"email" validate:""` // 6 to 20 characters Password string `json:"password" validate:"required,password"` }
type SignupResponse ¶
type VerifyEmailRequest ¶
type VerifyEmailResponse ¶
type VerifyEmailResponse struct {
Ok bool `json:"ok"`
}
Click to show internal directories.
Click to hide internal directories.