mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
asset viewer now viewing on tabs
Tabs is better for this yay Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// Reuses the app's own Sequelize connection/config instead of duplicating
|
||||
// DB_HOST/DB_PORT/... wiring — env.js pre-loads apps/api/.env so db.config.js
|
||||
// picks up the real dev credentials when it runs its own (no-op, already-set)
|
||||
// dotenv.config() call.
|
||||
require('./env');
|
||||
const sequelize = require('../../api/config/db.config');
|
||||
const Users = require('../../api/models/users/users.mdl');
|
||||
|
||||
async function getUserIdByEmail(email) {
|
||||
const user = await Users.findOne({ where: { email }, attributes: ['user_id'] });
|
||||
if (!user) throw new Error(`No user found for email ${email} — check the dev DB seed / helpers/env.js USERS config.`);
|
||||
return String(user.user_id);
|
||||
}
|
||||
|
||||
async function getPendingOtp(user_id) {
|
||||
const rows = await sequelize.query(
|
||||
`SELECT otp_code FROM users WHERE user_id = :uid`,
|
||||
{ replacements: { uid: user_id }, type: sequelize.QueryTypes.SELECT },
|
||||
);
|
||||
return rows[0]?.otp_code ?? null;
|
||||
}
|
||||
|
||||
module.exports = { sequelize, getUserIdByEmail, getPendingOtp };
|
||||
Reference in New Issue
Block a user