controllers

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUserFromContext

func GetUserFromContext(ctx *fiber.Ctx) (domain.User, error)

GetUserFromContext gets the user from the context.

func SetUserToContext

func SetUserToContext(ctx *fiber.Ctx, user domain.User)

SetUserToContext sets the user to the context.

Types

type AuthController

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

AuthController is the controller for the auth routes.

func NewAuthController

func NewAuthController(auth auth.IUseCase) AuthController

NewAuthController creates a new auth controller.

func (*AuthController) Login

func (a *AuthController) Login(c *fiber.Ctx) error

Login is the controller for the login route

@Summary		Login
@Description	Login
@Tags			Auth
@Accept			json
@Produce		json
@Param			login	body		domain.Login	true	"Login"
@Success		200		{object}	views.LoginTokenVM
@Failure		401		{object}	views.HTTPResponseVM
@Failure		500		{object}	views.HTTPResponseVM
@Router			/v2/security/login [post]

func (*AuthController) Logout

func (*AuthController) Logout(c *fiber.Ctx) error

Logout is the controller for the logout route

@Summary		Logout
@Description	Logout
@Tags			Auth
@Accept			json
@Produce		json
@Success		200	{object}	views.LoginTokenVM
@Failure		500	{object}	views.HTTPResponseVM
@Router			/v2/security/logout [post]

func (*AuthController) RefreshToken

func (a *AuthController) RefreshToken(c *fiber.Ctx) error

RefreshToken is the controller for the refresh token route

@Summary		Refresh token
@Description	Refresh token
@Tags			Auth
@Accept			json
@Produce		json
@Success		200	{object}	views.LoginTokenVM
@Failure		401	{object}	views.HTTPResponseVM
@Failure		500	{object}	views.HTTPResponseVM
@Router			/v2/security/refresh [post]

func (*AuthController) Register

func (a *AuthController) Register(c *fiber.Ctx) error

Register is the controller for the register route

@Summary		Register
@Description	Register
@Tags			Auth
@Accept			json
@Produce		json
@Param			register	body		domain.Register	true	"Register"
@Success		201			{object}	views.RegisterVM
@Failure		400			{object}	views.HTTPResponseVM
@Failure		500			{object}	views.HTTPResponseVM
@Router			/v2/security/register [post]

type CardController

type CardController struct {
	card.IUseCase
}

func NewCardController

func NewCardController(useCase card.IUseCase) CardController

type DeckController

type DeckController struct {
	deck.IUseCase
}

DeckController is the controller for the deck routes.

func NewDeckController

func NewDeckController(useCase deck.IUseCase) DeckController

NewDeckController returns a new deck controller.

func (*DeckController) Create

func (d *DeckController) Create(c *fiber.Ctx) error

Create is the controller for the create deck route

@Summary		Create deck
@Description	Create deck
@Tags			Deck
@Accept			json
@Produce		json
@Param			deck	body		domain.Deck	true	"Deck object"
@Success		201		{object}	views.HTTPResponseVM
@Failure		400		{object}	views.HTTPResponseVM
@Router			/v2/deck [post]
@Security		Bearer

func (*DeckController) GetByID

func (d *DeckController) GetByID(c *fiber.Ctx) error

GetByID is the controller for the get deck by id route

@Summary		Get deck by id
@Description	Get deck by id
@Tags			Deck
@Accept			json
@Produce		json
@Param			id	path		uint	true	"Deck ID"
@Success		200	{object}	views.HTTPResponseVM
@Failure		400	{object}	views.HTTPResponseVM
@Failure		403	{object}	views.HTTPResponseVM
@Failure		404	{object}	views.HTTPResponseVM
@Router			/v2/deck/{id} [get]
@Security		Bearer

func (*DeckController) GetLearning

func (d *DeckController) GetLearning(c *fiber.Ctx) error

GetLearning is the controller for the get learning decks route

@Summary		Get learning decks
@Description	Get learning decks
@Tags			Deck
@Accept			json
@Produce		json
@Success		200	{object}	views.HTTPResponseVM
@Failure		400	{object}	views.HTTPResponseVM
@Failure		404	{object}	views.HTTPResponseVM
@Router			/v2/deck/learning [get]
@Security		Bearer

func (*DeckController) GetOwned

func (d *DeckController) GetOwned(c *fiber.Ctx) error

GetOwned is the controller for the get owned decks route

@Summary		Get owned decks
@Description	Get owned decks
@Tags			Deck
@Accept			json
@Produce		json
@Success		200	{object}	views.HTTPResponseVM
@Failure		400	{object}	views.HTTPResponseVM
@Failure		404	{object}	views.HTTPResponseVM
@Router			/v2/deck/owned [get]
@Security		Bearer

func (*DeckController) GetPublic

func (d *DeckController) GetPublic(c *fiber.Ctx) error

GetPublic is the controller for the get public decks route

@Summary		Get public decks
@Description	Get public decks
@Tags			Deck
@Accept			json
@Produce		json
@Success		200	{object}	views.HTTPResponseVM
@Failure		400	{object}	views.HTTPResponseVM
@Failure		404	{object}	views.HTTPResponseVM
@Router			/v2/deck/public [get]
@Security		Bearer

type JSONHelperSingleton added in v1.2.2

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

func GetJSONHelperInstance added in v1.2.2

func GetJSONHelperInstance() *JSONHelperSingleton

func (*JSONHelperSingleton) GetJSONHelper added in v1.2.2

func (j *JSONHelperSingleton) GetJSONHelper() json.Helper

func (*JSONHelperSingleton) SetJSONHelper added in v1.2.2

func (j *JSONHelperSingleton) SetJSONHelper(helper json.Helper)

type JwtController

type JwtController struct {
	user.IUseCase
}

JwtController is the controller for the jwt routes.

func NewJwtController

func NewJwtController(user user.IUseCase) JwtController

NewJwtController creates a new jwt controller.

func (*JwtController) IsConnectedMiddleware

func (j *JwtController) IsConnectedMiddleware(p domain.Permission) func(c *fiber.Ctx) error

IsConnectedMiddleware checks if the user is connected and has the required permissions the permissions are defined in the route definition returns an error if the user is not connected or has not the required permissions

if the user is connected and has the required permissions, it sets the user in the locals and calls the next middleware.

func (*JwtController) VerifyPermissions

func (*JwtController) VerifyPermissions(user domain.User, p domain.Permission) bool

VerifyPermissions checks if the user has the required permissions.

type McqController

type McqController struct {
	mcq.IUseCase
}

func NewMcqController

func NewMcqController(useCase mcq.IUseCase) McqController

type OAuthController

type OAuthController struct {
	auth.IAuthRedisRepository
	// contains filtered or unexported fields
}

OAuthController is the controller for the OAuth routes.

func NewOAuthController

func NewOAuthController(auth auth.IUseCase, redisRepository auth.IAuthRedisRepository) OAuthController

NewOAuthController creates a new OAuthController.

func (*OAuthController) DiscordCallback

func (a *OAuthController) DiscordCallback(c *fiber.Ctx) error

DiscordCallback handles the callback from discord

@Summary		Handles the callback from discord
@Description	Handles the callback from discord
@Tags			OAuth
@Accept			json
@Produce		json
@Param			code	query		string					true	"code from discord"
@Success		200		{object}	views.LoginTokenVM		"login token"
@Failure		401		{object}	views.HTTPResponseVM	"invalid credentials"
@Failure		500		{object}	views.HTTPResponseVM	"internal server error"
@Router			/v2/security/discord_callback [get]

func (*OAuthController) DiscordLogin

func (a *OAuthController) DiscordLogin(c *fiber.Ctx) error

DiscordLogin redirects the user to the discord login page

@Summary		Redirects the user to the discord login page
@Description	Redirects the user to the discord login page
@Tags			OAuth
@Accept			json
@Produce		json
@Success		302	{string}	string					"redirecting to github login"
@Failure		500	{object}	views.HTTPResponseVM	"internal server error"
@Router			/v2/security/discord [get]

func (*OAuthController) GithubCallback

func (a *OAuthController) GithubCallback(c *fiber.Ctx) error

GithubCallback handles the callback from github

@Summary		Handles the callback from github
@Description	Handles the callback from github
@Tags			OAuth
@Accept			json
@Produce		json
@Param			code	query		string					true	"code from github"
@Success		200		{object}	views.LoginTokenVM		"login token"
@Failure		401		{object}	views.HTTPResponseVM	"invalid credentials"
@Failure		500		{object}	views.HTTPResponseVM	"internal server error"
@Router			/v2/security/github_callback [get]

func (*OAuthController) GithubLogin

func (a *OAuthController) GithubLogin(c *fiber.Ctx) error

GithubLogin redirects the user to the github login page

@Summary		Redirects the user to the github login page
@Description	Redirects the user to the github login page
@Tags			OAuth
@Accept			json
@Produce		json
@Success		302	{string}	string					"redirecting to github login"
@Failure		500	{object}	views.HTTPResponseVM	"internal server error"
@Router			/v2/security/github [get]

type UserController

type UserController struct {
	user.IUseCase
}

UserController is the controller for the user routes.

func NewUserController

func NewUserController(useCase user.IUseCase) UserController

NewUserController creates a new user controller.

func (*UserController) GetMe

func (*UserController) GetMe(c *fiber.Ctx) error

GetMe returns the user from the context.

func (*UserController) GetName

func (u *UserController) GetName(c *fiber.Ctx) error

GetName returns the name of the user.

Jump to

Keyboard shortcuts

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