@base44-preview/cli 0.0.50-pr.475.9d797d7 → 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 CHANGED
@@ -243244,6 +243244,7 @@ var package_default = {
243244
243244
  typescript: "^5.7.2",
243245
243245
  vitest: "^4.0.16",
243246
243246
  yaml: "^2.8.2",
243247
+ qs: "^6.12.3",
243247
243248
  zod: "^4.3.5"
243248
243249
  },
243249
243250
  engines: {
@@ -253460,26 +253461,30 @@ var createJwtToken = (email3) => {
253460
253461
  expiresIn: "360d"
253461
253462
  });
253462
253463
  };
253463
- var UserRegiterSchema = object({
253464
- id: string2(),
253465
- email: email2(),
253466
- otpCode: string2().length(6),
253467
- password: string2().min(8),
253468
- createdAt: number2().min(1)
253469
- });
253470
253464
  function createAuthRouter(db2, logger2) {
253471
253465
  const router = import_express2.Router({ mergeParams: true });
253472
- const userRegitrPendingMap = new Map;
253466
+ const userRegistrPendingMap = new Map;
253473
253467
  const parseBody = import_express2.json();
253474
253468
  router.post("/login", parseBody, async (req, res) => {
253475
- const { email: email3, password: _password } = req.body;
253469
+ const { email: email3, password } = req.body;
253476
253470
  const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: email3 });
253477
253471
  if (result) {
253478
- res.json({
253479
- access_token: createJwtToken(email3),
253480
- success: true,
253481
- user: {}
253482
- });
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
+ }
253483
253488
  return;
253484
253489
  }
253485
253490
  res.status(401).json({ error: "Unauthorized" });
@@ -253509,7 +253514,7 @@ function createAuthRouter(db2, logger2) {
253509
253514
  }
253510
253515
  const otpCode = generateCode();
253511
253516
  const id2 = nanoid3();
253512
- userRegitrPendingMap.set(email3, {
253517
+ userRegistrPendingMap.set(email3, {
253513
253518
  id: id2,
253514
253519
  email: email3,
253515
253520
  otpCode,
@@ -253527,9 +253532,10 @@ In order to complete registration use this verification code: ${otpCode}
253527
253532
  });
253528
253533
  router.post("/verify-otp", parseBody, async (req, res) => {
253529
253534
  const { email: email3, otp_code } = req.body;
253530
- const userData = userRegitrPendingMap.get(email3);
253535
+ const userData = userRegistrPendingMap.get(email3);
253531
253536
  if (userData && userData.otpCode === otp_code) {
253532
253537
  if (+Date.now() - userData.createdAt < 10 * 60 * 1000) {
253538
+ userData.otpCode = undefined;
253533
253539
  const collection = db2.getCollection(USER_COLLECTION);
253534
253540
  const now = getNowISOTimestamp();
253535
253541
  const nameFromEmailMatch = /^([^@]+)/.exec(email3);
@@ -255715,7 +255721,7 @@ class WatchBase44 extends EventEmitter4 {
255715
255721
  var DEFAULT_PORT = 4400;
255716
255722
  var BASE44_APP_URL = "https://base44.app";
255717
255723
  async function createDevServer(options8) {
255718
- const { port: userPort, cwd } = options8;
255724
+ const { port: userPort } = options8;
255719
255725
  const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
255720
255726
  const baseUrl = `http://localhost:${port}`;
255721
255727
  const { functions, entities, project: project2 } = await options8.loadResources();
@@ -260359,4 +260365,4 @@ export {
260359
260365
  CLIExitError
260360
260366
  };
260361
260367
 
260362
- //# debugId=5FDDF606296BF31964756E2164756E21
260368
+ //# debugId=404C42E5E0DB4C5E64756E2164756E21