api

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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} response.Error @Failure 401 {object} response.Unauthorized @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 SignInApi

type SignInApi struct {
	core.Api
}

func NewSignInApi

func NewSignInApi() *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} response.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 {
	core.Api
}

func NewSignOutApi

func NewSignOutApi() *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} response.Error @Failure 401 {object} response.Unauthorized @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} response.Error @Success 200 {object} response.User @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