models

package
v0.0.0-...-4d8659c Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Id          string `json:"client_id"`
	Secret      string `json:"secret"`
	RedirectUrl string `json:"redirect_url"`
}

Client represents an OAuth client with its ID, secret, and redirect URL.

type ClientOutput

type ClientOutput struct {
	Id          string `json:"client_id"`    // Id is the client's ID.
	RedirectUrl string `json:"redirect_url"` // RedirectUrl is the client's redirect URL.
}

ClientOutput represents the output of a client.

type CreateClientRequestBody

type CreateClientRequestBody struct {
	Secret      string `json:"secret"`       // Secret is the client's secret.
	RedirectUrl string `json:"redirect_url"` // RedirectUrl is the client's redirect URL.
}

CreateClientRequestBody represents the request body for creating a new client.

type CreateClientResponseBody

type CreateClientResponseBody struct {
	ClientId    string `json:"client_id"`    // ClientId is the ID of the client.
	RedirectUrl string `json:"redirect_url"` // RedirectUrl is the client's redirect URL.
}

CreateClientResponseBody represents the response body for creating a new client.

type CreateUserRequestBody

type CreateUserRequestBody struct {
	Password string `json:"password"` // Password is the user's password.
	Email    string `json:"email"`    // Email is the user's email address.
}

CreateUserRequestBody represents the request body for creating a new user.

type Database

type Database interface {
	// CreateClient inserts a new client into the database.
	CreateClient(c *Client) error

	// CreateUser inserts a new user into the database.
	CreateUser(u *UserAccount) error

	// DeleteClient removes a client from the database by their client ID.
	DeleteClient(clientID string) error

	// DeleteUser removes a user from the database by their user ID.
	DeleteUser(userID string) error

	// GetClients retrieves a list of clients from the database with pagination.
	GetClients(offset, limit int) ([]*ClientOutput, error)

	// GetClientById retrieves a client from the database by their client ID.
	GetClientById(clientID string) (*Client, error)

	// GetUsers retrieves a list of users from the database with pagination.
	GetUsers(offset, limit int) ([]*UserAccountOutput, error)

	// GetUserById retrieves a user from the database by their user ID.
	GetUserById(userID string) (*UserAccount, error)

	// GetUserByEmail retrieves a user from the database by their email.
	GetUserByEmail(email string) (*UserAccount, error)

	// UpdateClient updates an existing client's information in the database.
	UpdateClient(c *Client) error

	// UpdateUser updates an existing user's information in the database.
	UpdateUser(u *UserAccount) error
}

Database defines the interface for database operations related to clients and users.

type RenewTokenRequestBody

type RenewTokenRequestBody struct {
	*TokenResponse
	AccessToken string `json:"access_token"` // AccessToken is the access token to be renewed.
}

RenewTokenRequestBody represents the request body for renewing a token.

type Role

type Role string

Role defines the role of a user in the system.

const (
	// ADMIN represents an administrative user role.
	ADMIN Role = "ADMIN"
	// USER represents a standard user role.
	USER Role = "USER"
)

func (Role) IsValid

func (r Role) IsValid() bool

IsValid checks if the role is a valid role (either ADMIN or USER).

type SetUserPasswordRequestBody

type SetUserPasswordRequestBody struct {
	Password string `json:"password"` // Password is the new password for the user.
}

SetUserPasswordRequestBody represents the request body for setting a user's password.

type SmtpConfig

type SmtpConfig struct {
	Host     string // Host is the SMTP server address.
	Port     int    // Port is the port number for the SMTP server.
	User     string // User is the username for SMTP authentication.
	Password string // Password is the password for SMTP authentication.
}

SmtpConfig represents the configuration settings for an SMTP server.

type TokenResponse

type TokenResponse struct {
	TokenType string    `json:"token_type"` // TokenType is the type of the token.
	Expires   time.Time `json:"expires_in"` // Expires is the expiration time of the token.
}

TokenResponse represents the response containing token type and expiration time.

type TokenResponseBody

type TokenResponseBody struct {
	*TokenResponse
	AccessToken  string `json:"access_token"`  // AccessToken is the access token.
	RefreshToken string `json:"refresh_token"` // RefreshToken is the refresh token.
}

TokenResponseBody represents the response body containing tokens and token response.

type UserAccount

type UserAccount struct {
	Uuid     string `json:"uuid"`
	Password string `json:"password"`
	Email    string `json:"email"`
	Role     Role   `json:"role"`
}

UserAccount represents a user account with its UUID, password, email, and role.

type UserAccountOutput

type UserAccountOutput struct {
	Uuid  string `json:"uuid"`  // Uuid is the unique identifier of the user.
	Email string `json:"email"` // Email is the user's email address.
	Role  Role   `json:"role"`  // Role is the user's role.
}

UserAccountOutput represents the output of a user account.

Jump to

Keyboard shortcuts

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