api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ForgotPWApi

type ForgotPWApi struct {
	core.Api
}

ForgotPWApi API struct.

func NewForgotPWApi

func NewForgotPWApi() *ForgotPWApi

NewForgotPWApi As a constructor to get forgot password API. Related with NewResetPWApi

func (*ForgotPWApi) Handle

func (h *ForgotPWApi) Handle(c *core.Ctx) error

Handle method to forget password. @Summary Forgot password @Description Forgot password. @Tags Password @Accept json @Produce json @Param data body request.ForgotPassword true "Forgot password payload" @Success 204 @Failure 400 {object} http.Error @Router /password/forgot [post]

func (*ForgotPWApi) Validate

func (h *ForgotPWApi) Validate(c *core.Ctx) error

Validate Verify data from request.

type RefreshTokenApi

type RefreshTokenApi struct {
	core.Api
}

func NewRefreshTokenApi

func NewRefreshTokenApi() *RefreshTokenApi

NewRefreshTokenApi As a constructor to create new API.

func (*RefreshTokenApi) Handle

func (h *RefreshTokenApi) Handle(c *core.Ctx) error

Handle method to refresh user token. @Description Refresh user token @Summary refresh user token @Tags Auth @Accept json @Produce json @Param data body request.RefreshToken true "RefreshToken payload" @Failure 400 {object} http.Error @Failure 401 {object} http.Error @Success 200 {object} response.SignIn @Security ApiKeyAuth @Router /auth/refresh [put]

func (*RefreshTokenApi) Validate

func (h *RefreshTokenApi) Validate(c *core.Ctx) error

Validate validates request refresh token

type ResetPWApi

type ResetPWApi struct {
	core.Api
}

ResetPWApi API struct.

func NewResetPWApi

func NewResetPWApi() *ResetPWApi

NewResetPWApi As a constructor to get reset password API. Related with NewForgotPWApi

func (*ResetPWApi) Handle

func (h *ResetPWApi) Handle(c *core.Ctx) error

Handle method to reset password. @Summary Reset password @Description Reset password. @Tags Password @Accept json @Produce json @Param data body request.ResetPassword true "Reset password payload" @Success 204 @Failure 400 {object} http.Error @Router /password/reset [post]

func (*ResetPWApi) Validate

func (h *ResetPWApi) Validate(c *core.Ctx) error

Validate Verify data from request.

type SignInApi

type SignInApi struct {
	Type auth.Type
	core.Api
}

func NewSignInApi

func NewSignInApi(authType auth.Type) *SignInApi

NewSignInApi is a constructor

func (*SignInApi) Handle

func (h *SignInApi) Handle(c *core.Ctx) error

Handle func handle sign in user then returns access token and refresh token @Description Authenticating user's credentials then return access and refresh token if valid. Otherwise, return an error message. @Summary authenticating user's credentials @Tags Auth @Accept json @Produce json @Param data body request.SignIn true "Signin payload" @Success 200 {object} response.SignIn @Failure 400 {object} http.Error @Router /auth/signin [post]

func (*SignInApi) Validate

func (h *SignInApi) Validate(c *core.Ctx) error

Validate data from request

type SignOutApi

type SignOutApi struct {
	Type auth.Type
	core.Api
}

func NewSignOutApi

func NewSignOutApi(authType auth.Type) *SignOutApi

NewSignOutApi As a constructor to create new API.

func (*SignOutApi) Handle

func (h *SignOutApi) Handle(c *core.Ctx) error

Handle method to invalidate users access token by adding them to a blacklist in Redis and delete refresh token from the Redis @Description De-authorize user and delete refresh token from Redis. @Summary de-authorize user and delete refresh token from Redis @Tags Auth @Accept json @Produce json @Failure 400 {object} http.Error @Failure 401 {object} http.Error @Success 204 @Security ApiKeyAuth @Router /auth/signout [delete]

type SignUp

type SignUp struct {
	core.Api
}

func NewSignUpApi

func NewSignUpApi() *SignUp

func (*SignUp) Handle

func (h *SignUp) Handle(c *core.Ctx) error

Handle function handle sign up user includes create user, create user's role. @Description Create a new user with `request.SignUp` body then add `role id` to table `user_roles` with current `user id` @Summary Sign up a new user @Tags Auth @Accept json @Produce json @Param data body request.SignUp true "Signup payload" @Failure 400 {object} http.Error @Success 200 {object} response.SignUp @Router /auth/signup [post]

func (*SignUp) Validate

func (h *SignUp) Validate(c *core.Ctx) error

Jump to

Keyboard shortcuts

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