domain

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

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotAllowed            = errors.New("user not allowed")
	ErrUserNotFound              = errors.New("user not found")
	ErrUnauthorized              = errors.New("unauthorized")
	ErrInvalidPassword           = errors.New("invalid password")
	ErrUserShouldLoginWithGoogle = errors.New("user should login with Google")
	ErrCodeExchangeWrong         = errors.New("code exchange wrong")
	ErrFailedGetGoogleUser       = errors.New("failed to get google user")
	ErrFailedToReadResponse      = errors.New("failed to read response")
	ErrUnexpectedSigningMethod   = errors.New("unexpected signing method")
	ErrInvalidToken              = errors.New("invalid token")
)

Error List:

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type GoogleUseCase

type GoogleUseCase interface {
	GoogleLogin(ctx context.Context, data []byte, env *bootstrap.Env) (accessToken string, refreshToken string, err error)
	GetUserDataFromGoogle(googleOauthConfig *oauth2.Config, code, oauthGoogleUrlAPI string) ([]byte, error)
	GenerateStateOauthCookie(w http.ResponseWriter) string
}

type GoogleUser

type GoogleUser struct {
	Id            string `json:"id"`
	Email         string `json:"email"`
	VerifiedEmail bool   `json:"verified_email"`
	Name          string `json:"name"`
	GivenName     string `json:"given_name"`
	FamilyName    string `json:"family_name"`
	Picture       string `json:"picture"`
	Locale        string `json:"locale"`
}

type JwtCustomClaims

type JwtCustomClaims struct {
	Name     string `json:"name"`
	ID       int    `json:"id"`
	Email    string `json:"email"`
	GoogleId string `json:"google_id"`
	jwt.RegisteredClaims
}

type JwtCustomRefreshClaims

type JwtCustomRefreshClaims struct {
	Name     string `json:"name"`
	ID       int    `json:"id"`
	Email    string `json:"email"`
	GoogleId string `json:"google_id"`
	jwt.RegisteredClaims
}

type LoginRequest

type LoginRequest struct {
	Email    string `form:"email" binding:"required,email"`
	Password string `form:"password" binding:"required"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type LoginUseCase

type LoginUseCase interface {
	Login(ctx context.Context, request LoginRequest, env *bootstrap.Env) (accessToken string, refreshToken string, err error)
}

type RefreshTokenRequest

type RefreshTokenRequest struct {
	RefreshToken string `form:"refreshToken" binding:"required"`
}

type RefreshTokenResponse

type RefreshTokenResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type RefreshTokenUseCase

type RefreshTokenUseCase interface {
	RefreshToken(ctx context.Context, request RefreshTokenRequest, env *bootstrap.Env) (accessToken string, refreshToken string, err error)
}

type SignupRequest

type SignupRequest struct {
	Name     string `form:"name" binding:"required"`
	Email    string `form:"email" binding:"required,email"`
	Password string `form:"password" binding:"required"`
}

type SignupResponse

type SignupResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type SignupUseCase

type SignupUseCase interface {
	SignUp(ctx context.Context, request SignupRequest, env *bootstrap.Env) (accessToken string, refreshToken string, err error)
}

type User

type User struct {
	Id             int       `json:"id" db:"id"`
	GoogleId       string    `json:"google_id" db:"google_id"`
	ProfilePicture string    `json:"profile_picture" db:"profile_picture"`
	Name           string    `json:"name" db:"name"`
	Password       string    `json:"password" db:"password"`
	Email          string    `json:"email" db:"email"`
	Phone          string    `json:"phone" db:"phone"`
	CreatedAt      time.Time `json:"created_at" db:"created_at"`
	UpdatedAt      time.Time `json:"updated_at" db:"updated_at"`
}

type UserResponse

type UserResponse struct {
	Id             int       `json:"id" db:"id"`
	GoogleId       string    `json:"google_id" db:"google_id"`
	ProfilePicture string    `json:"profile_picture" db:"profile_picture"`
	Name           string    `json:"name" db:"name"`
	Email          string    `json:"email" db:"email"`
	Phone          string    `json:"phone" db:"phone"`
	CreatedAt      time.Time `json:"created_at" db:"created_at"`
}

type UserUseCase

type UserUseCase interface {
	GetUserById(c context.Context, id int) (*UserResponse, error)
	GetUsers(c context.Context) ([]*UserResponse, error)
	UpdateUser(c context.Context, user *User) error
	DeleteUser(c context.Context, id int) error
}

Jump to

Keyboard shortcuts

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