Shoraky commited on
Commit
b3f8039
·
1 Parent(s): 0ffd170

Return subscription access on login

Browse files
Files changed (1) hide show
  1. src/server.ts +2 -1
src/server.ts CHANGED
@@ -300,7 +300,8 @@ app.post("/api/auth/login", authLimiter, async (req, res, next) => {
300
  if (error || !data.user || !data.session) return res.status(401).json({ error: "Invalid email or password." });
301
  await syncProfile(data.user);
302
  setSessionCookies(res, data.session);
303
- return res.json({ user: userPayload(data.user) });
 
304
  } catch (error) { next(error); }
305
  });
306
 
 
300
  if (error || !data.user || !data.session) return res.status(401).json({ error: "Invalid email or password." });
301
  await syncProfile(data.user);
302
  setSessionCookies(res, data.session);
303
+ const subscription = await activeSubscriptionFor(data.user.id);
304
+ return res.json({ user: userPayload(data.user), access: { active: Boolean(subscription), subscription } });
305
  } catch (error) { next(error); }
306
  });
307