Documentation ¶
Index ¶
- Constants
- Variables
- func Auth(role role) echo.MiddlewareFunc
- func DeleteAccount(c echo.Context) error
- func ForgotPassword(c echo.Context) error
- func GetAccessToken(c echo.Context) error
- func GetAllUsers(c echo.Context) error
- func GetEcho() *echo.Echo
- func GetFile(c echo.Context) error
- func GetFileList(c echo.Context) error
- func GetMe(c echo.Context) error
- func GetOAuth2UserEmail(c echo.Context, config *oauth2.Config, userDataEndpoint string) (string, error)
- func LogIn(c echo.Context) error
- func LogOut(c echo.Context) error
- func OAuth2Callback(c echo.Context) error
- func OAuth2LogIn(c echo.Context) error
- func PutFile(c echo.Context) error
- func RegisterRoutes(e *echo.Echo)
- func ResetPassword(c echo.Context) error
- func SendPasswordChangeEmail(c echo.Context) error
- func SignUp(c echo.Context) error
- type AuthRequest
- type ForgotPasswordRequest
- type LogInRequest
- type LogInResponse
- type OAuth2CallbackRequest
- type OAuth2LogInRequest
- type ResetPasswordRequest
- type SignUpRequest
- type SignUpResponse
Constants ¶
const ( RoleUser role = iota + 1 RoleStaff RoleAdmin )
Variables ¶
var (
ErrUserNotLoggedIn = errors.New("user is not logged in")
)
Functions ¶
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 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 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 RegisterRoutes ¶
func RegisterRoutes(e *echo.Echo)
func ResetPassword ¶
func ResetPassword(c echo.Context) error
func SendPasswordChangeEmail ¶
func SendPasswordChangeEmail(c echo.Context) error
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 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 SignUpRequest ¶
type SignUpResponse ¶
type SignUpResponse struct {
AccessToken string `json:"access_token"`
}