handler

package
v0.0.0-...-a78aad3 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleUser role = iota + 1
	RoleStaff
	RoleAdmin
)

Variables

View Source
var (
	ErrUserNotLoggedIn = errors.New("user is not logged in")
)

Functions

func Auth

func Auth(role role) echo.MiddlewareFunc

func DeleteAccount

func DeleteAccount(c echo.Context) error

func ForgotPassword

func ForgotPassword(c echo.Context) error

@Summary Send password reset email @Description Send password reset email @Tags auth @Param body body ForgotPasswordRequest true "Body" @Accept application/json @Produce application/json @Router /auth/forgot-password [POST] @Success 200 {object} string

func GetAccessToken

func GetAccessToken(c echo.Context) error

@Summary Get access token @Description Get access token if user is logged in @Tags auth @Accept application/json @Produce application/json @Router /auth/access-token [GET] @Success 200 string any @Failure 401 string httputil.HTTPError

func GetAllUsers

func GetAllUsers(c echo.Context) error

@Summary Get all users @Description Get all users @Tags users @Param Authorization header string true "Access token" @Accept application/json @Produce application/json @Router /users/me [GET] @Success 200 {object} []repo.User @Failure 500 string any

func GetEcho

func GetEcho() *echo.Echo

@host localhost:8443

func GetFile

func GetFile(c echo.Context) error

func GetFileList

func GetFileList(c echo.Context) error

func GetMe

func GetMe(c echo.Context) error

@Summary Get me @Description Get info of current user @Tags users @Param Authorization header string true "Access token" @Accept application/json @Produce application/json @Router /users [GET] @Success 200 {object} repo.User @Failure 500 string any

func GetOAuth2UserEmail

func GetOAuth2UserEmail(c echo.Context, config *oauth2.Config, userDataEndpoint string) (string, error)

func LogIn

func LogIn(c echo.Context) error

@Summary Log in @Description Log into application @Tags auth @Param body body LogInRequest true "Body" @Accept application/json @Produce application/json @Router /auth/log-in [POST] @Success 200 {object} LogInResponse @Failure 401 string httputil.HTTPError

func LogOut

func LogOut(c echo.Context) error

@Summary Log out @Description Log out of application @Tags auth @Produce application/json @Router /auth/log-out [POST] @Success 200

func OAuth2Callback

func OAuth2Callback(c echo.Context) error

func OAuth2LogIn

func OAuth2LogIn(c echo.Context) error

@Summary OAuth2 Login @Description Log in with OAuth2 @Tags auth @Accept application/json @Produce application/json @Router /auth/oauth2/{provider} [GET] @Param provider path string true "OAuth2 provider" @Success 200 object LogInResponse @Failure 500 string any

func PutFile

func PutFile(c echo.Context) error

func RegisterRoutes

func RegisterRoutes(e *echo.Echo)

func ResetPassword

func ResetPassword(c echo.Context) error

func SendPasswordChangeEmail

func SendPasswordChangeEmail(c echo.Context) error

func SignUp

func SignUp(c echo.Context) error

@Summary Sign up @Description Sign up for application @Tags auth @Accept multipart/form-data @Produce application/json @Router /auth/sign-up [POST] @Success 200 {object} SignUpResponse

Types

type AuthRequest

type AuthRequest struct {
	Authorization string `header:"Authorization" validate:"required,startswith=Bearer "`
}

type ForgotPasswordRequest

type ForgotPasswordRequest struct {
	Email string `json:"email" validate:"required,email"`
}

type LogInRequest

type LogInRequest struct {
	Email    string `form:"email" json:"email" validate:"required,email"`
	Password string `form:"password" json:"password" validate:"required"`
}

type LogInResponse

type LogInResponse struct {
	AccessToken string `json:"access_token"`
}

type OAuth2CallbackRequest

type OAuth2CallbackRequest struct {
	Provider string `param:"provider" validate:"required,oneof=google github discord"`
}

type OAuth2LogInRequest

type OAuth2LogInRequest struct {
	Provider string `param:"provider" validate:"required,oneof=google github discord"`
}

type ResetPasswordRequest

type ResetPasswordRequest struct {
	Token       string `form:"token" query:"token" validate:"required"`
	NewPassword string `form:"new_password" validate:"required,min=8,max=512"`
}

type SignUpRequest

type SignUpRequest struct {
	Email           string `json:"email" validate:"required,email"`
	Password        string `json:"password" validate:"required,min=8,max=512"`
	ConfirmPassword string `json:"confirm_password" validate:"required,eqcsfield=Password"`
}

type SignUpResponse

type SignUpResponse struct {
	AccessToken string `json:"access_token"`
}

Jump to

Keyboard shortcuts

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