Skip to content

Commit af3f632

Browse files
committed
fixed: two decrypt password
1 parent 443484c commit af3f632

File tree

7 files changed

+5588
-859
lines changed

7 files changed

+5588
-859
lines changed

server/package-lock.json

Lines changed: 5306 additions & 854 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"push:migrate": "drizzle-kit push:pg",
2323
"drop:migrate": "drizzle-kit drop",
2424
"check:migrate": "drizzle-kit check:pg",
25-
"db:studio": "drizzle-kit studio --port 5050",
25+
"db:studio": "drizzle-kit studio --port 9000",
2626
"db:seed": "ts-node -r tsconfig-paths/register --transpile-only src/database/seed.ts",
2727
"typesafe-i18n": "typesafe-i18n",
2828
"debug": "concurrently cross-env nodemon --exec \"node --inspect=0.0.0.0:9229 --require ts-node/register -r tsconfig-paths/register src/server.ts\" "
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "channels" ADD COLUMN "user_id" text NOT NULL;
Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
{
2+
"id": "136b3e7d-3833-460d-8b70-6c1f72f312a9",
3+
"prevId": "c34fe41e-ca68-4197-a176-a16e17424b10",
4+
"version": "5",
5+
"dialect": "pg",
6+
"tables": {
7+
"channel_types": {
8+
"name": "channel_types",
9+
"schema": "",
10+
"columns": {
11+
"id": {
12+
"name": "id",
13+
"type": "varchar(36)",
14+
"primaryKey": true,
15+
"notNull": true
16+
},
17+
"name": {
18+
"name": "name",
19+
"type": "text",
20+
"primaryKey": false,
21+
"notNull": true
22+
},
23+
"description": {
24+
"name": "description",
25+
"type": "text",
26+
"primaryKey": false,
27+
"notNull": true
28+
},
29+
"deleted": {
30+
"name": "deleted",
31+
"type": "boolean",
32+
"primaryKey": false,
33+
"notNull": false,
34+
"default": false
35+
}
36+
},
37+
"indexes": {},
38+
"foreignKeys": {},
39+
"compositePrimaryKeys": {},
40+
"uniqueConstraints": {
41+
"channel_types_name_unique": {
42+
"name": "channel_types_name_unique",
43+
"nullsNotDistinct": false,
44+
"columns": [
45+
"name"
46+
]
47+
},
48+
"channel_types_description_unique": {
49+
"name": "channel_types_description_unique",
50+
"nullsNotDistinct": false,
51+
"columns": [
52+
"description"
53+
]
54+
}
55+
}
56+
},
57+
"channels": {
58+
"name": "channels",
59+
"schema": "",
60+
"columns": {
61+
"id": {
62+
"name": "id",
63+
"type": "varchar(36)",
64+
"primaryKey": true,
65+
"notNull": true
66+
},
67+
"contact_id": {
68+
"name": "contact_id",
69+
"type": "text",
70+
"primaryKey": false,
71+
"notNull": true
72+
},
73+
"contact_name": {
74+
"name": "contact_name",
75+
"type": "text",
76+
"primaryKey": false,
77+
"notNull": true
78+
},
79+
"credentials": {
80+
"name": "credentials",
81+
"type": "text",
82+
"primaryKey": false,
83+
"notNull": false
84+
},
85+
"active": {
86+
"name": "active",
87+
"type": "boolean",
88+
"primaryKey": false,
89+
"notNull": false
90+
},
91+
"deleted": {
92+
"name": "deleted",
93+
"type": "boolean",
94+
"primaryKey": false,
95+
"notNull": false,
96+
"default": false
97+
},
98+
"channel_type_id": {
99+
"name": "channel_type_id",
100+
"type": "text",
101+
"primaryKey": false,
102+
"notNull": true
103+
},
104+
"user_id": {
105+
"name": "user_id",
106+
"type": "text",
107+
"primaryKey": false,
108+
"notNull": true
109+
},
110+
"created_at": {
111+
"name": "created_at",
112+
"type": "timestamp",
113+
"primaryKey": false,
114+
"notNull": false,
115+
"default": "now()"
116+
},
117+
"updated_at": {
118+
"name": "updated_at",
119+
"type": "timestamp",
120+
"primaryKey": false,
121+
"notNull": false
122+
}
123+
},
124+
"indexes": {},
125+
"foreignKeys": {},
126+
"compositePrimaryKeys": {},
127+
"uniqueConstraints": {
128+
"channels_contact_id_unique": {
129+
"name": "channels_contact_id_unique",
130+
"nullsNotDistinct": false,
131+
"columns": [
132+
"contact_id"
133+
]
134+
}
135+
}
136+
},
137+
"settings": {
138+
"name": "settings",
139+
"schema": "",
140+
"columns": {
141+
"id": {
142+
"name": "id",
143+
"type": "varchar(36)",
144+
"primaryKey": true,
145+
"notNull": true
146+
},
147+
"email": {
148+
"name": "email",
149+
"type": "json",
150+
"primaryKey": false,
151+
"notNull": true,
152+
"default": "'{\"email\":\"\",\"password\":\"\"}'::json"
153+
},
154+
"user_id": {
155+
"name": "user_id",
156+
"type": "varchar(36)",
157+
"primaryKey": false,
158+
"notNull": true
159+
}
160+
},
161+
"indexes": {},
162+
"foreignKeys": {
163+
"settings_user_id_users_id_fk": {
164+
"name": "settings_user_id_users_id_fk",
165+
"tableFrom": "settings",
166+
"tableTo": "users",
167+
"columnsFrom": [
168+
"user_id"
169+
],
170+
"columnsTo": [
171+
"id"
172+
],
173+
"onDelete": "no action",
174+
"onUpdate": "no action"
175+
}
176+
},
177+
"compositePrimaryKeys": {},
178+
"uniqueConstraints": {}
179+
},
180+
"users": {
181+
"name": "users",
182+
"schema": "",
183+
"columns": {
184+
"id": {
185+
"name": "id",
186+
"type": "varchar(36)",
187+
"primaryKey": true,
188+
"notNull": true
189+
},
190+
"email": {
191+
"name": "email",
192+
"type": "text",
193+
"primaryKey": false,
194+
"notNull": true
195+
},
196+
"password": {
197+
"name": "password",
198+
"type": "text",
199+
"primaryKey": false,
200+
"notNull": false
201+
},
202+
"name": {
203+
"name": "name",
204+
"type": "text",
205+
"primaryKey": false,
206+
"notNull": true
207+
},
208+
"avatar": {
209+
"name": "avatar",
210+
"type": "text",
211+
"primaryKey": false,
212+
"notNull": false
213+
},
214+
"role": {
215+
"name": "role",
216+
"type": "roles[]",
217+
"primaryKey": false,
218+
"notNull": true
219+
},
220+
"provider": {
221+
"name": "provider",
222+
"type": "text",
223+
"primaryKey": false,
224+
"notNull": true,
225+
"default": "'local'"
226+
}
227+
},
228+
"indexes": {
229+
"email_idx": {
230+
"name": "email_idx",
231+
"columns": [
232+
"email"
233+
],
234+
"isUnique": true
235+
}
236+
},
237+
"foreignKeys": {},
238+
"compositePrimaryKeys": {},
239+
"uniqueConstraints": {
240+
"users_email_unique": {
241+
"name": "users_email_unique",
242+
"nullsNotDistinct": false,
243+
"columns": [
244+
"email"
245+
]
246+
}
247+
}
248+
}
249+
},
250+
"enums": {
251+
"roles": {
252+
"name": "roles",
253+
"values": {
254+
"ADMIN": "ADMIN",
255+
"USER": "USER"
256+
}
257+
}
258+
},
259+
"schemas": {},
260+
"_meta": {
261+
"columns": {},
262+
"schemas": {},
263+
"tables": {}
264+
}
265+
}

server/src/database/migrations/meta/_journal.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
"when": 1708877973296,
1616
"tag": "0001_yielding_mad_thinker",
1717
"breakpoints": true
18+
},
19+
{
20+
"idx": 2,
21+
"version": "5",
22+
"when": 1709131241663,
23+
"tag": "0002_faulty_iron_fist",
24+
"breakpoints": true
1825
}
1926
]
2027
}

server/src/database/schema.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ export const settings = pgTable('settings', {
104104
});
105105

106106
export const usersRelations = relations(users, ({ one, many }) => ({
107-
settings: one(settings),
107+
settings: one(settings, {
108+
relationName: 'userSettings',
109+
fields: [users.id],
110+
references: [settings.userId],
111+
}),
108112
channels: many(channels),
109113
}));

server/src/services/setting.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class SettingService {
3434
.set({
3535
email: {
3636
email,
37-
password: decrypt(password),
37+
password,
3838
},
3939
})
4040
.where(eq(settings.userId, userId))
@@ -49,14 +49,14 @@ export class SettingService {
4949
userId,
5050
email: {
5151
email,
52-
password: decrypt(password),
52+
password,
5353
},
5454
})
5555
.returning({
5656
email: settings.email,
5757
});
5858

59-
return settingInserted;
59+
return encrypt(JSON.stringify(settingInserted));
6060
}
6161

6262
return encrypt(JSON.stringify(emailSetting));

0 commit comments

Comments
 (0)