This commit is contained in:
@@ -47,7 +47,7 @@ func (h *AuthController) Signin(c fiber.Ctx) error {
|
||||
|
||||
if err := validator.ValidateBodyDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func (h *AuthController) Signup(c fiber.Ctx) error {
|
||||
|
||||
if err := validator.ValidateBodyDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
@@ -220,7 +220,7 @@ func (h *AuthController) VerifyToken(c fiber.Ctx) error {
|
||||
|
||||
if err := validator.ValidateBodyDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func (h *AuthController) CreateToken(c fiber.Ctx) error {
|
||||
|
||||
if err := validator.ValidateBodyDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
@@ -294,7 +294,7 @@ func (h *AuthController) ForgotPassword(c fiber.Ctx) error {
|
||||
|
||||
if err := validator.ValidateBodyDto(c, dto); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(response.CommonResponse{
|
||||
Status: false,
|
||||
Status: false,
|
||||
Errors: err,
|
||||
})
|
||||
}
|
||||
@@ -438,11 +438,9 @@ func (h *AuthController) GoogleCallback(c fiber.Ctx) error {
|
||||
})
|
||||
|
||||
allowed := map[string]bool{
|
||||
"http://localhost:3000": true,
|
||||
"https://localhost:3000": true,
|
||||
"http://localhost:3001": true,
|
||||
"https://localhost:3001": true,
|
||||
"http://localhost:5500": true,
|
||||
"http://localhost:3000": true,
|
||||
"http://localhost:3001": true,
|
||||
"https://history-admin.kain.id.vn": true,
|
||||
}
|
||||
feUrl := config.GetConfigWithDefault("FRONTEND_URL", "http://localhost:3000")
|
||||
redirectURL := data.RedirectURL
|
||||
|
||||
@@ -59,6 +59,21 @@ func (e *MediaEntity) ToResponse() *response.MediaResponse {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *MediaSimpleEntity) ToResponse() *response.MediaSimpleResponse {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
return &response.MediaSimpleResponse{
|
||||
ID: e.ID,
|
||||
StorageKey: e.StorageKey,
|
||||
OriginalName: e.OriginalName,
|
||||
MimeType: e.MimeType,
|
||||
Size: e.Size,
|
||||
FileMetadata: e.FileMetadata,
|
||||
CreatedAt: e.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *MediaEntity) ToSimpleEntity() *MediaSimpleEntity {
|
||||
if e == nil {
|
||||
return nil
|
||||
@@ -76,6 +91,9 @@ func (e *MediaEntity) ToSimpleEntity() *MediaSimpleEntity {
|
||||
|
||||
func MediaEntitiesToResponse(entities []*MediaEntity) []*response.MediaResponse {
|
||||
responses := make([]*response.MediaResponse, 0)
|
||||
if entities == nil {
|
||||
return responses
|
||||
}
|
||||
for _, entity := range entities {
|
||||
if entity == nil {
|
||||
continue
|
||||
@@ -87,6 +105,9 @@ func MediaEntitiesToResponse(entities []*MediaEntity) []*response.MediaResponse
|
||||
|
||||
func MediaEntitiesToStorageEntity(entities []*MediaEntity) []*MediaStorageEntity {
|
||||
responses := make([]*MediaStorageEntity, 0)
|
||||
if entities == nil {
|
||||
return responses
|
||||
}
|
||||
for _, entity := range entities {
|
||||
if entity == nil {
|
||||
continue
|
||||
@@ -95,3 +116,17 @@ func MediaEntitiesToStorageEntity(entities []*MediaEntity) []*MediaStorageEntity
|
||||
}
|
||||
return responses
|
||||
}
|
||||
|
||||
func MediaSimpleEntitiesToResponse(entities []*MediaSimpleEntity) []*response.MediaSimpleResponse {
|
||||
responses := make([]*response.MediaSimpleResponse, 0)
|
||||
if entities == nil {
|
||||
return responses
|
||||
}
|
||||
for _, entity := range entities {
|
||||
if entity == nil {
|
||||
continue
|
||||
}
|
||||
responses = append(responses, entity.ToResponse())
|
||||
}
|
||||
return responses
|
||||
}
|
||||
|
||||
@@ -62,6 +62,9 @@ func (r *RoleEntity) ToRoleSimple() *RoleSimple {
|
||||
|
||||
func RolesEntityToResponse(rs []*RoleEntity) []*response.RoleResponse {
|
||||
out := make([]*response.RoleResponse, 0)
|
||||
if rs == nil {
|
||||
return out
|
||||
}
|
||||
for _, role := range rs {
|
||||
if role == nil {
|
||||
continue
|
||||
@@ -73,12 +76,15 @@ func RolesEntityToResponse(rs []*RoleEntity) []*response.RoleResponse {
|
||||
|
||||
func RolesEntityToRoleConstant(rs []*RoleSimple) []constants.Role {
|
||||
out := make([]constants.Role, 0)
|
||||
if rs == nil {
|
||||
return out
|
||||
}
|
||||
for _, role := range rs {
|
||||
data, ok := constants.ParseRole(role.Name)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
out= append(out, data)
|
||||
out = append(out, data)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -75,6 +75,9 @@ func (u *UserEntity) ToResponse() *response.UserResponse {
|
||||
|
||||
func UsersEntityToResponse(users []*UserEntity) []*response.UserResponse {
|
||||
out := make([]*response.UserResponse, 0)
|
||||
if users == nil {
|
||||
return out
|
||||
}
|
||||
for _, user := range users {
|
||||
if user == nil {
|
||||
continue
|
||||
|
||||
@@ -53,21 +53,9 @@ func (u *UserVerificationEntity) ParseReviewer(data []byte) error {
|
||||
}
|
||||
|
||||
func (u *UserVerificationEntity) ToResponse() *response.UserVerificationResponse {
|
||||
mediaResponses := make([]*response.MediaSimpleResponse, 0)
|
||||
for _, m := range u.Media {
|
||||
if m != nil {
|
||||
mediaResponses = append(mediaResponses, &response.MediaSimpleResponse{
|
||||
ID: m.ID,
|
||||
StorageKey: m.StorageKey,
|
||||
OriginalName: m.OriginalName,
|
||||
MimeType: m.MimeType,
|
||||
Size: m.Size,
|
||||
FileMetadata: m.FileMetadata,
|
||||
CreatedAt: m.CreatedAt,
|
||||
})
|
||||
}
|
||||
if u == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
res := &response.UserVerificationResponse{
|
||||
ID: u.ID,
|
||||
User: u.User.ToResponse(),
|
||||
@@ -78,7 +66,7 @@ func (u *UserVerificationEntity) ToResponse() *response.UserVerificationResponse
|
||||
Reviewer: u.Reviewer.ToResponse(),
|
||||
ReviewedAt: u.ReviewedAt,
|
||||
CreatedAt: u.CreatedAt,
|
||||
Medias: mediaResponses,
|
||||
Medias: MediaSimpleEntitiesToResponse(u.Media),
|
||||
}
|
||||
|
||||
if u.ReviewedAt != nil {
|
||||
@@ -90,6 +78,9 @@ func (u *UserVerificationEntity) ToResponse() *response.UserVerificationResponse
|
||||
|
||||
func UserVerificationsEntitiesToResponse(entities []*UserVerificationEntity) []*response.UserVerificationResponse {
|
||||
responses := make([]*response.UserVerificationResponse, 0)
|
||||
if entities == nil {
|
||||
return responses
|
||||
}
|
||||
for _, entity := range entities {
|
||||
if entity == nil {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user