blixify-server 0.2.15 → 0.2.16

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.
@@ -9,10 +9,12 @@ export declare class AuthWrapper {
9
9
  lib: WrapperLib;
10
10
  constructor(fbAdmin: any, isProd: boolean, lib: WrapperLib);
11
11
  initCheckAuthMethod: (req: any, res: any) => Promise<void>;
12
- initDisableAccount: (req: any, res: any) => Promise<void>;
13
- initUpdatePassword: (req: any, res: any) => Promise<void>;
12
+ initCreateAccount: (req: any, res: any, workflow?: () => Promise<any>) => Promise<void>;
13
+ initDisableAccount: (req: any, res: any, workflow?: () => Promise<any>) => Promise<void>;
14
+ initUpdatePassword: (req: any, res: any, workflow?: () => Promise<any>) => Promise<void>;
14
15
  initUpdateEmail: (req: any, res: any, workflow?: () => Promise<any>) => Promise<void>;
15
16
  initUpdateMobileNo: (req: any, res: any, workflow?: () => Promise<any>) => Promise<void>;
17
+ initDeleteAccount: (req: any, res: any, workflow?: () => Promise<any>) => Promise<void>;
16
18
  init: () => any;
17
19
  }
18
20
  //# sourceMappingURL=authWrapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/authWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,EAAE,GAAG,CAAM;IAClB,MAAM,UAAS;IACf,GAAG,EAAE,UAAU,CAAC;gBAEJ,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU;IAM1D,mBAAmB,QAAe,GAAG,OAAO,GAAG,mBAyB7C;IAEF,kBAAkB,QAAe,GAAG,OAAO,GAAG,mBAW5C;IAEF,kBAAkB,QAAe,GAAG,OAAO,GAAG,mBAW5C;IAEF,eAAe,QACR,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAiB7B;IAEF,kBAAkB,QACX,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAa7B;IAEF,IAAI,YAiDF;CACH"}
1
+ {"version":3,"file":"authWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/authWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,EAAE,GAAG,CAAM;IAClB,MAAM,UAAS;IACf,GAAG,EAAE,UAAU,CAAC;gBAEJ,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU;IAM1D,mBAAmB,QAAe,GAAG,OAAO,GAAG,mBAyB7C;IAEF,iBAAiB,QACV,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAwB7B;IAEF,kBAAkB,QACX,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAa7B;IAEF,kBAAkB,QACX,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAa7B;IAEF,eAAe,QACR,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAiB7B;IAEF,kBAAkB,QACX,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAa7B;IAEF,iBAAiB,QACV,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAY7B;IAEF,IAAI,YAsEF;CACH"}
@@ -47,7 +47,34 @@ class AuthWrapper {
47
47
  res.status(400).json({ err: err });
48
48
  }
49
49
  });
50
- this.initDisableAccount = (req, res) => __awaiter(this, void 0, void 0, function* () {
50
+ this.initCreateAccount = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
51
+ const adminAuth = this.fbAdmin.auth();
52
+ try {
53
+ const userId = req.body.userId;
54
+ const phoneNumber = req.body.phoneNumber;
55
+ const email = req.body.email;
56
+ const password = req.body.password;
57
+ if (!userId)
58
+ throw "Invalid Configuration";
59
+ const userData = {
60
+ uid: userId,
61
+ };
62
+ if (phoneNumber)
63
+ userData["phoneNumber"] = phoneNumber;
64
+ if (email)
65
+ userData["email"] = email;
66
+ if (password)
67
+ userData["password"] = password;
68
+ const createdCredentials = yield adminAuth.createUser(userData);
69
+ if (workflow)
70
+ yield workflow();
71
+ res.send({ success: createdCredentials.uid });
72
+ }
73
+ catch (err) {
74
+ res.status(400).json({ err: err });
75
+ }
76
+ });
77
+ this.initDisableAccount = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
51
78
  const adminAuth = this.fbAdmin.auth();
52
79
  try {
53
80
  const userId = req.body.userId;
@@ -55,13 +82,15 @@ class AuthWrapper {
55
82
  if (!userId)
56
83
  throw "Invalid Configuration";
57
84
  yield adminAuth.updateUser(userId, { disabled: disable ? true : false });
85
+ if (workflow)
86
+ yield workflow();
58
87
  res.send({ success: true });
59
88
  }
60
89
  catch (err) {
61
90
  res.status(400).json({ err: err });
62
91
  }
63
92
  });
64
- this.initUpdatePassword = (req, res) => __awaiter(this, void 0, void 0, function* () {
93
+ this.initUpdatePassword = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
65
94
  const adminAuth = this.fbAdmin.auth();
66
95
  try {
67
96
  const userId = req.body.userId;
@@ -69,6 +98,8 @@ class AuthWrapper {
69
98
  if (!userId || !password)
70
99
  throw "Invalid Configuration";
71
100
  yield adminAuth.updateUser(userId, { password: password });
101
+ if (workflow)
102
+ yield workflow();
72
103
  res.send({ success: true });
73
104
  }
74
105
  catch (err) {
@@ -111,6 +142,21 @@ class AuthWrapper {
111
142
  res.status(400).json({ err: err });
112
143
  }
113
144
  });
145
+ this.initDeleteAccount = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
146
+ const adminAuth = this.fbAdmin.auth();
147
+ try {
148
+ const userId = req.body.userId;
149
+ if (!userId)
150
+ throw "Invalid Configuration";
151
+ yield adminAuth.deleteUser(userId);
152
+ if (workflow)
153
+ yield workflow();
154
+ res.send({ success: true });
155
+ }
156
+ catch (err) {
157
+ res.status(400).json({ err: err });
158
+ }
159
+ });
114
160
  this.init = () => {
115
161
  const router = this.lib.express.Router();
116
162
  /**
@@ -128,6 +174,17 @@ class AuthWrapper {
128
174
  router.post("/method", (req, res) => {
129
175
  this.initCheckAuthMethod(req, res);
130
176
  });
177
+ /**
178
+ * @Input
179
+ * userId - string
180
+ * phoneNumber? - string
181
+ * email? - string
182
+ * password? - string
183
+ *
184
+ */
185
+ router.post("/create", (req, res) => {
186
+ this.initCreateAccount(req, res);
187
+ });
131
188
  /**
132
189
  * @Input
133
190
  * userId - string
@@ -153,6 +210,14 @@ class AuthWrapper {
153
210
  router.post("/mobile", (req, res) => {
154
211
  this.initUpdateMobileNo(req, res);
155
212
  });
213
+ /**
214
+ * @Input
215
+ * userId - string
216
+ *
217
+ */
218
+ router.post("/delete", (req, res) => {
219
+ this.initDeleteAccount(req, res);
220
+ });
156
221
  return router;
157
222
  };
158
223
  this.fbAdmin = fbAdmin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blixify-server",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "license": "MIT",
5
5
  "main": "dist/apis/index.js",
6
6
  "private": false,