propro-utils 1.5.17 → 1.5.19
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/middlewares/account_info.js +6 -13
- package/package.json +1 -1
- package/src/server/index.js +13 -0
|
@@ -67,19 +67,12 @@ const getAccountProfile = async (redisClient, userSchema, accountId) => {
|
|
|
67
67
|
*/
|
|
68
68
|
const checkIfUserExists = async (userSchema, accountId) => {
|
|
69
69
|
const user = await userSchema.findOne({ accountId });
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
return user;
|
|
78
|
-
} catch (error) {
|
|
79
|
-
throw new Error('Error creating user');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return user;
|
|
70
|
+
if (user) return user;
|
|
71
|
+
return await userSchema.create({
|
|
72
|
+
accountId,
|
|
73
|
+
id: uuidv4(),
|
|
74
|
+
verified: false,
|
|
75
|
+
});
|
|
83
76
|
};
|
|
84
77
|
|
|
85
78
|
module.exports = {
|
package/package.json
CHANGED
package/src/server/index.js
CHANGED
|
@@ -52,6 +52,7 @@ class AuthMiddleware {
|
|
|
52
52
|
initializeRoutes() {
|
|
53
53
|
this.router.post('/api/auth', this.handleAuth);
|
|
54
54
|
this.router.post('/api/login', this.handleLogin);
|
|
55
|
+
this.router.post('/api/magiclink', this.handleMagicLink);
|
|
55
56
|
this.router.post('/api/register', this.handleRegister);
|
|
56
57
|
this.router.get('/api/callback', this.handleCallback);
|
|
57
58
|
this.router.post('/api/refreshToken', this.handleRefreshToken);
|
|
@@ -99,6 +100,18 @@ class AuthMiddleware {
|
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
102
|
|
|
103
|
+
handleMagicLink = async (req, res) => {
|
|
104
|
+
try {
|
|
105
|
+
const response = await this.proxyToAuthServer(
|
|
106
|
+
req,
|
|
107
|
+
'/api/v1/auth/send-magic-link'
|
|
108
|
+
);
|
|
109
|
+
res.status(response.status).json(response.data);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
this.handleProxyError(error, res);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
102
115
|
handleRegister = async (req, res) => {
|
|
103
116
|
const { returnTokens } = req.query;
|
|
104
117
|
|