UPDATE: Auth module, User module
Some checks failed
Build and Release / release (push) Failing after 1m25s
Some checks failed
Build and Release / release (push) Failing after 1m25s
This commit is contained in:
@@ -1,11 +1,36 @@
|
||||
package request
|
||||
|
||||
import "history-api/pkg/constants"
|
||||
|
||||
type SignUpDto struct {
|
||||
Email string `json:"email" validate:"required,min=5,max=255,email"`
|
||||
Password string `json:"password" validate:"required,min=8,max=64"`
|
||||
DisplayName string `json:"display_name" validate:"required,min=2,max=50"`
|
||||
TokenID string `json:"token_id" validate:"required,uuid"`
|
||||
}
|
||||
type SignInDto struct {
|
||||
Email string `json:"email" validate:"required,min=5,max=255,email"`
|
||||
Password string `json:"password" validate:"required,min=8,max=64"`
|
||||
}
|
||||
|
||||
type CreateTokenDto struct {
|
||||
Email string `json:"email" validate:"required,email"`
|
||||
TokenType constants.TokenType `json:"token_type" validate:"required,oneof=1 2 3 4"`
|
||||
}
|
||||
|
||||
type VerifyTokenDto struct {
|
||||
Email string `json:"email" validate:"required,email"`
|
||||
TokenType constants.TokenType `json:"token_type" validate:"required,oneof=1 2 3 4"`
|
||||
Token string `json:"token" validate:"required,len=6,numeric"`
|
||||
}
|
||||
|
||||
type ForgotPasswordDto struct {
|
||||
TokenID string `json:"token_id" validate:"required,uuid"`
|
||||
Email string `json:"email" validate:"required,min=5,max=255,email"`
|
||||
NewPassword string `json:"new_password" validate:"required,min=8,max=64"`
|
||||
}
|
||||
|
||||
type SigninWith3rdDto struct {
|
||||
Provider string `json:"provider" validate:"required,oneof=google github facebook"`
|
||||
AccessToken string `json:"access_token" validate:"required"`
|
||||
}
|
||||
|
||||
@@ -1,26 +1,42 @@
|
||||
package request
|
||||
|
||||
import "history-api/pkg/constant"
|
||||
|
||||
type CreateUserDto struct {
|
||||
Username string `json:"username" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
DiscordUserId string `json:"discord_user_id" validate:"required"`
|
||||
Role []constant.Role `json:"role" validate:"required"`
|
||||
type UpdateProfileDto struct {
|
||||
DisplayName string `json:"display_name" validate:"omitempty,min=2,max=50"`
|
||||
FullName string `json:"full_name" validate:"omitempty,min=2,max=100"`
|
||||
AvatarUrl string `json:"avatar_url" validate:"omitempty,url"`
|
||||
Bio string `json:"bio" validate:"omitempty,max=255"`
|
||||
Location string `json:"location" validate:"omitempty,max=100"`
|
||||
Website string `json:"website" validate:"omitempty,url"`
|
||||
CountryCode string `json:"country_code" validate:"omitempty,len=2"`
|
||||
Phone string `json:"phone" validate:"omitempty,min=8,max=20"`
|
||||
}
|
||||
|
||||
type UpdateUserDto struct {
|
||||
Password *string `json:"password" validate:"omitempty"`
|
||||
DiscordUserId *string `json:"discord_user_id" validate:"omitempty"`
|
||||
Role *[]constant.Role `json:"role" validate:"omitempty"`
|
||||
type ChangePasswordDto struct {
|
||||
OldPassword string `json:"old_password" validate:"required,min=8,max=64"`
|
||||
NewPassword string `json:"new_password" validate:"required,min=8,max=64,nefield=OldPassword"`
|
||||
}
|
||||
|
||||
type ChangeRoleDto struct {
|
||||
UserID string `json:"user_id" validate:"required,uuid"`
|
||||
Roles []string `json:"role_ids" validate:"required,min=1,dive,required,uuid"`
|
||||
}
|
||||
|
||||
type GetAllUserDto struct {
|
||||
CursorPaginationDto
|
||||
IsDeleted *bool `json:"is_deleted" query:"is_deleted" validate:"omitempty"`
|
||||
RoleIDs []string `json:"role_ids" query:"role_ids" validate:"omitempty,dive,uuid"`
|
||||
}
|
||||
|
||||
type CursorPaginationDto struct {
|
||||
Cursor string `json:"cursor" query:"cursor" validate:"omitempty,uuid"`
|
||||
Limit int `json:"limit" query:"limit" validate:"required,min=1,max=100"`
|
||||
Sort string `json:"sort" query:"sort" validate:"omitempty,oneof=created_at updated_at email display_name"`
|
||||
Order string `json:"order" query:"order" validate:"omitempty,oneof=asc desc"`
|
||||
}
|
||||
|
||||
type SearchUserDto struct {
|
||||
Username *string `query:"username" validate:"omitempty"`
|
||||
DiscordUserId *string `query:"discord_user_id" validate:"omitempty"`
|
||||
Role *[]constant.Role `query:"role" validate:"omitempty"`
|
||||
SortBy string `query:"sort_by" default:"created_at" validate:"oneof=created_at updated_at"`
|
||||
Order string `query:"order" default:"desc" validate:"oneof=asc desc"`
|
||||
Page int `query:"page" default:"1" validate:"min=1"`
|
||||
Limit int `query:"limit" default:"10" validate:"min=1,max=100"`
|
||||
CursorPaginationDto
|
||||
Search string `json:"search" query:"search" validate:"omitempty,min=2,max=200"`
|
||||
IsDeleted *bool `json:"is_deleted" query:"is_deleted" validate:"omitempty"`
|
||||
RoleIDs []string `json:"role_ids" query:"role_ids" validate:"omitempty,dive,uuid"`
|
||||
}
|
||||
|
||||
@@ -4,3 +4,7 @@ type AuthResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}
|
||||
|
||||
type VerifyTokenResponse struct {
|
||||
TokenID string `json:"token_id"`
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"history-api/pkg/constant"
|
||||
"history-api/pkg/constants"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
@@ -13,7 +13,18 @@ type CommonResponse struct {
|
||||
}
|
||||
|
||||
type JWTClaims struct {
|
||||
UId string `json:"uid"`
|
||||
Roles []constant.Role `json:"roles"`
|
||||
UId string `json:"uid"`
|
||||
Roles []constants.Role `json:"roles"`
|
||||
TokenVersion int32 `json:"token_version"`
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
}
|
||||
|
||||
type PaginatedResponse struct {
|
||||
Data any `json:"data"`
|
||||
Status bool `json:"status"`
|
||||
Message string `json:"message"`
|
||||
Pagination struct {
|
||||
NextCursor string `json:"next_cursor"`
|
||||
HasMore bool `json:"has_more"`
|
||||
} `json:"pagination"`
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package response
|
||||
|
||||
import "time"
|
||||
|
||||
type TokenResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
TokenType int16 `json:"token_type"`
|
||||
ExpiresAt *time.Time `json:"expires_at"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
}
|
||||
Reference in New Issue
Block a user