ztechno_core 0.0.44 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/user_service.d.ts +9 -1
- package/lib/user_service.js +19 -7
- package/package.json +1 -1
package/lib/user_service.d.ts
CHANGED
|
@@ -12,7 +12,15 @@ export declare class ZUserService {
|
|
|
12
12
|
register({ email, pass, role, admin }: ZRequiredUserColumns): Promise<{
|
|
13
13
|
session: string;
|
|
14
14
|
}>;
|
|
15
|
-
find(
|
|
15
|
+
find(
|
|
16
|
+
opt:
|
|
17
|
+
| {
|
|
18
|
+
email: string;
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
user_id: number;
|
|
22
|
+
},
|
|
23
|
+
): Promise<ZUser | undefined>;
|
|
16
24
|
auth(opt: ZUserSession | ZUserCredentials): Promise<{
|
|
17
25
|
user?: ZUser;
|
|
18
26
|
session?: string;
|
package/lib/user_service.js
CHANGED
|
@@ -60,13 +60,25 @@ class ZUserService {
|
|
|
60
60
|
return { session };
|
|
61
61
|
}
|
|
62
62
|
async find(opt) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
if (opt.email !== undefined) {
|
|
64
|
+
const rows = await this.sqlService.query(
|
|
65
|
+
`
|
|
66
|
+
SELECT user_id, email, session, role, admin, updated_at, created_at FROM \`${this.tableName}\`
|
|
67
|
+
WHERE email=?`,
|
|
68
|
+
[opt.email],
|
|
69
|
+
);
|
|
70
|
+
return rows[0];
|
|
71
|
+
} else if (opt.user_id !== undefined) {
|
|
72
|
+
const rows = await this.sqlService.query(
|
|
73
|
+
`
|
|
74
|
+
SELECT user_id, email, session, role, admin, updated_at, created_at FROM \`${this.tableName}\`
|
|
75
|
+
WHERE user_id=?`,
|
|
76
|
+
[opt.user_id],
|
|
77
|
+
);
|
|
78
|
+
return rows[0];
|
|
79
|
+
} else {
|
|
80
|
+
throw new Error(`Unexpected Input for ZUserService.find(${JSON.stringify(opt)})`);
|
|
81
|
+
}
|
|
70
82
|
}
|
|
71
83
|
async auth(opt) {
|
|
72
84
|
if (!opt.session && !opt.email && !opt.pass) {
|