Skip to content

Commit ecd8f44

Browse files
committed
fix(user): changes in migration schema, include password in response
1 parent 0ef93cf commit ecd8f44

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

docs/openapi.json

+3
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@
565565
"email": {
566566
"type": "string"
567567
},
568+
"password": {
569+
"type": "string"
570+
},
568571
"name": {
569572
"type": "string"
570573
},
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
CREATE TABLE
22
`users` (
33
`wallet_address` varchar(42) NOT NULL,
4-
`email` varchar(100) NOT NULL,
4+
`email` varchar(100) NOT NULL UNIQUE,
55
`password` varchar(100) NOT NULL,
66
`sss_1` varchar(100) NOT NULL,
77
`name` varchar(255) NOT NULL,
88
`email_verified_at` timestamp NULL DEFAULT NULL,
99
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
1010
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
1111
PRIMARY KEY (`wallet_address`)
12-
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
12+
);

module/user/interfaces/http/dto.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,22 @@ type UpdateUserPasswordRequest struct {
3535
NewPassword string `json:"newPassword" validate:"required"`
3636
}
3737

38+
type CreateUserResponse struct {
39+
SSS2 string `json:"sss2"`
40+
SSS3 string `json:"sss3"`
41+
}
42+
3843
type GetUserResponse struct {
39-
WalletAddress string `json:"wallet_address"`
44+
WalletAddress string `json:"walletAddress"`
4045
Email string `json:"email"`
46+
Password string `json:"password"`
4147
Name string `json:"name"`
42-
EmailVerifiedAt *uint64 `json:"email_verified_at"`
43-
CreatedAt uint64 `json:"created_at"`
44-
UpdatedAt uint64 `json:"updated_at"`
48+
EmailVerifiedAt *uint64 `json:"emailVerifiedAt"`
49+
CreatedAt uint64 `json:"createdAt"`
50+
UpdatedAt uint64 `json:"updatedAt"`
4551
}
4652

4753
type GetPaginatedUserResponse struct {
48-
Users []GetUserResponse `json:"users"`
49-
TotalCount uint `json:"total_count"`
50-
}
51-
52-
type CreateUserResponse struct {
53-
SSS2 string `json:"sss2"`
54-
SSS3 string `json:"sss3"`
54+
Users []GetUserResponse `json:"users"`
55+
Total uint `json:"total"`
5556
}

module/user/interfaces/http/rest/UserQueryController.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func (controller *UserQueryController) GetUsers(w http.ResponseWriter, r *http.R
8888
users = append(users, types.GetUserResponse{
8989
WalletAddress: user.WalletAddress,
9090
Email: user.Email,
91+
Password: user.Password,
9192
Name: user.Name,
9293
EmailVerifiedAt: emailVerifiedTimestamp,
9394
CreatedAt: uint64(user.CreatedAt.Unix()),
@@ -100,8 +101,8 @@ func (controller *UserQueryController) GetUsers(w http.ResponseWriter, r *http.R
100101
Success: true,
101102
Message: "Successfully fetched all users.",
102103
Data: &types.GetPaginatedUserResponse{
103-
Users: users,
104-
TotalCount: totalCount,
104+
Users: users,
105+
Total: totalCount,
105106
},
106107
}
107108

@@ -215,6 +216,7 @@ func (controller *UserQueryController) GetUserByWalletAddress(w http.ResponseWri
215216
user := &types.GetUserResponse{
216217
WalletAddress: res.WalletAddress,
217218
Email: res.Email,
219+
Password: res.Password,
218220
Name: res.Name,
219221
CreatedAt: uint64(res.CreatedAt.Unix()),
220222
UpdatedAt: uint64(res.UpdatedAt.Unix()),

0 commit comments

Comments
 (0)