@base44-preview/cli 0.0.50-pr.475.145bd51 → 0.0.50-pr.475.b600821
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/dist/cli/index.js +22 -17
- package/dist/cli/index.js.map +5 -5
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -253461,26 +253461,30 @@ var createJwtToken = (email3) => {
|
|
|
253461
253461
|
expiresIn: "360d"
|
|
253462
253462
|
});
|
|
253463
253463
|
};
|
|
253464
|
-
var UserRegiterSchema = object({
|
|
253465
|
-
id: string2(),
|
|
253466
|
-
email: email2(),
|
|
253467
|
-
otpCode: string2().length(6),
|
|
253468
|
-
password: string2().min(8),
|
|
253469
|
-
createdAt: number2().min(1)
|
|
253470
|
-
});
|
|
253471
253464
|
function createAuthRouter(db2, logger2) {
|
|
253472
253465
|
const router = import_express2.Router({ mergeParams: true });
|
|
253473
|
-
const
|
|
253466
|
+
const userRegistrPendingMap = new Map;
|
|
253474
253467
|
const parseBody = import_express2.json();
|
|
253475
253468
|
router.post("/login", parseBody, async (req, res) => {
|
|
253476
|
-
const { email: email3, password
|
|
253469
|
+
const { email: email3, password } = req.body;
|
|
253477
253470
|
const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: email3 });
|
|
253478
253471
|
if (result) {
|
|
253479
|
-
|
|
253480
|
-
|
|
253481
|
-
|
|
253482
|
-
|
|
253483
|
-
|
|
253472
|
+
const registeredUserData = userRegistrPendingMap.get(email3);
|
|
253473
|
+
if (result.role === "admin" || registeredUserData?.password === password) {
|
|
253474
|
+
res.json({
|
|
253475
|
+
access_token: createJwtToken(email3),
|
|
253476
|
+
success: true,
|
|
253477
|
+
user: {}
|
|
253478
|
+
});
|
|
253479
|
+
} else {
|
|
253480
|
+
res.status(400).json({
|
|
253481
|
+
detail: "Invalid email or password",
|
|
253482
|
+
error_type: "HTTPException",
|
|
253483
|
+
message: "Invalid email or password",
|
|
253484
|
+
request_id: null,
|
|
253485
|
+
traceback: ""
|
|
253486
|
+
});
|
|
253487
|
+
}
|
|
253484
253488
|
return;
|
|
253485
253489
|
}
|
|
253486
253490
|
res.status(401).json({ error: "Unauthorized" });
|
|
@@ -253510,7 +253514,7 @@ function createAuthRouter(db2, logger2) {
|
|
|
253510
253514
|
}
|
|
253511
253515
|
const otpCode = generateCode();
|
|
253512
253516
|
const id2 = nanoid3();
|
|
253513
|
-
|
|
253517
|
+
userRegistrPendingMap.set(email3, {
|
|
253514
253518
|
id: id2,
|
|
253515
253519
|
email: email3,
|
|
253516
253520
|
otpCode,
|
|
@@ -253528,9 +253532,10 @@ In order to complete registration use this verification code: ${otpCode}
|
|
|
253528
253532
|
});
|
|
253529
253533
|
router.post("/verify-otp", parseBody, async (req, res) => {
|
|
253530
253534
|
const { email: email3, otp_code } = req.body;
|
|
253531
|
-
const userData =
|
|
253535
|
+
const userData = userRegistrPendingMap.get(email3);
|
|
253532
253536
|
if (userData && userData.otpCode === otp_code) {
|
|
253533
253537
|
if (+Date.now() - userData.createdAt < 10 * 60 * 1000) {
|
|
253538
|
+
userData.otpCode = undefined;
|
|
253534
253539
|
const collection = db2.getCollection(USER_COLLECTION);
|
|
253535
253540
|
const now = getNowISOTimestamp();
|
|
253536
253541
|
const nameFromEmailMatch = /^([^@]+)/.exec(email3);
|
|
@@ -260360,4 +260365,4 @@ export {
|
|
|
260360
260365
|
CLIExitError
|
|
260361
260366
|
};
|
|
260362
260367
|
|
|
260363
|
-
//# debugId=
|
|
260368
|
+
//# debugId=404C42E5E0DB4C5E64756E2164756E21
|