auth

package
v0.0.0-...-42c0c98 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalLogin

func LocalLogin(client *ent.Client) gin.HandlerFunc

LocalLogin godoc

@Summary		Login with a local account
@Schemes		http https
@Description	Login with a local account
@Tags			Auth API
@Accept			json,mpfd
@Param			login	body	auth.UserLoginVals	true	"User account details"
@Produce		json
@Success		200	{object}	auth.UserModel
@Header			200	{string}	Cookie	"`auth-cookie` contains the session token"
@Router			/auth/local/login [post]

func Logout

func Logout(client *ent.Client) gin.HandlerFunc

Logout decodes the share session cookie and packs the session into context

func RegisterAuthEndpoints

func RegisterAuthEndpoints(client *ent.Client, r *gin.RouterGroup)

Types

type APIError

type APIError struct {
	Message string `json:"message"`
	Error   error  `json:"error"`
}

type UserLoginVals

type UserLoginVals struct {
	Username string `form:"username" json:"username" binding:"required" example:"admin"`
	Password string `form:"password" json:"password" binding:"required" example:"password123"`
}

UserLoginVals model info

@Description	Used as an input to the login input

type UserModel

type UserModel struct {
	// Fields
	ID        uuid.UUID `json:"id" example:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"` // Compsole ID
	Username  string    `json:"username" example:"compsole"`                       // [REQUIRED] The username for the user.
	FirstName string    `json:"first_name" example:"Default"`                      // [OPTIONAL] The display first name for the user.
	LastName  string    `json:"last_name" example:"User"`                          // [OPTIONAL] The display last name for the user.
	Role      user.Role `json:"role" example:"USER"`                               // [REQUIRED] The role of the user. Admins have full access.
	// Edges
	UserToTeam *rest.TeamEdge `json:"user_to_team"`
}

UserModel model info

@Description	Used for User login

func UserEntToModel

func UserEntToModel(entUser *ent.User) UserModel

UserEntToModel converts the result of a User ENT query into a UserModel for API responses

Jump to

Keyboard shortcuts

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