apis

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticateRequestThenLoadAuthContext

func AuthenticateRequestThenLoadAuthContext(app core.App) gin.HandlerFunc

func AuthorizeRequest

func AuthorizeRequest(app core.App) gin.HandlerFunc

func BindAccountApi

func BindAccountApi(app core.App, rg *gin.RouterGroup)

func BindAuthApi

func BindAuthApi(app core.App, rg *gin.RouterGroup, addResetPasswordEndpoint bool)

func BindFilesApi

func BindFilesApi(app core.App, r *gin.RouterGroup)

func BindHealthApi

func BindHealthApi(rg *gin.RouterGroup)

func Cors

func Cors(allowedOrigins string, router *gin.Engine)

func Endpoints

func Endpoints(app core.App, endpoints config.Endpoints)

func HandleError

func HandleError(c *gin.Context, err error)

func NewBadRequestError

func NewBadRequestError(c *gin.Context, message string, errors any)

func NewFilesApi

func NewFilesApi(app core.App) *filesApi

func NewForbiddenError

func NewForbiddenError(c *gin.Context)

func NewInternalServerError

func NewInternalServerError(c *gin.Context)

func NewNotFoundError

func NewNotFoundError(c *gin.Context)

func NewUnauthorizedError

func NewUnauthorizedError(c *gin.Context)

func RequestLogger

func RequestLogger(app core.App) gin.HandlerFunc

func Serve

func Serve(app core.App, config config.ServeConfig) error

func TenantMiddleware

func TenantMiddleware(app core.App) gin.HandlerFunc

Types

type ApiError

type ApiError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Errors  any    `json:"errors"`

} // @name ApiError

func NewApiError

func NewApiError(code int, message string, errors any) *ApiError

func (*ApiError) Error

func (e *ApiError) Error() string

type AuthApi

type AuthApi struct {
	// contains filtered or unexported fields
}

func NewAuthApi

func NewAuthApi(app core.App) *AuthApi

func (*AuthApi) AuthResponseWithUserInfoMap

func (api *AuthApi) AuthResponseWithUserInfoMap(c *gin.Context, identity string, userInfo map[string]any)

Todo: look for better way to represent user information

func (*AuthApi) AuthResponseWithUserType

func (api *AuthApi) AuthResponseWithUserType(c *gin.Context, user entities.User)

func (*AuthApi) ChangePassword

func (api *AuthApi) ChangePassword(c *gin.Context)

ChangePassword godoc @Summary change user's password @Description allow a user to change its password. @Tags auth @Accept json @Produce json @Param request body requests.PasswordChangeRequest true "Password Change request" @Security BearerAuth @Success 200 {object} responses.ApiResponse @Failure 401 {object} apis.ApiError @Failure 500 {object} apis.ApiError @Router /change-password [put]

func (AuthApi) GetTokenAndRefreshToken

func (api AuthApi) GetTokenAndRefreshToken(id uuid.UUID, identity string, role types.Role) (string, string, error)

func (*AuthApi) InitiateResetPassword

func (api *AuthApi) InitiateResetPassword(c *gin.Context)

InitiateResetPassword godoc @Summary initiate password reset process for user @Description start the process of resetting user's password @Tags auth @Accept json @Produce json @Param request body requests.ResetPasswordRequest true "Reset password request" @Security BearerAuth @Success 200 {object} responses.ApiResponse @Failure 401 {object} apis.ApiError @Failure 500 {object} apis.ApiError @Router /reset-password [put]

func (*AuthApi) Login

func (api *AuthApi) Login(c *gin.Context)

Login godoc @Summary Login a user @Description authenticate a user returning auth token, refresh token and user information @Tags auth @Accept json @Param request body requests.LoginRequest true "Login request" @Produce json @Success 200 {object} responses.AuthResponse @Failure 500 {object} apis.ApiError @Router /Login [post]

func (*AuthApi) RefreshToken

func (api *AuthApi) RefreshToken(c *gin.Context)

RefreshToken godoc @Summary refresh an auth token @Description get a new auth token with the refresh token for user @Tags auth @Accept json @Produce json @Param request body requests.RefreshTokenRequest true "Refresh token request" @Security BearerAuth @Success 200 {object} responses.AuthResponse @Failure 401 {object} apis.ApiError @Failure 500 {object} apis.ApiError @Router /refresh-token [put]

func (*AuthApi) ResetPassword

func (a *AuthApi) ResetPassword(c *gin.Context)

func (*AuthApi) ValidateResetPassword

func (api *AuthApi) ValidateResetPassword(c *gin.Context)

Jump to

Keyboard shortcuts

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