mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-04-21 12:10:17 -04:00
Implement getUser methods
This commit is contained in:
parent
743dec9c38
commit
956ba14e29
|
@ -12,7 +12,7 @@ import {
|
||||||
|
|
||||||
export const router = Router();
|
export const router = Router();
|
||||||
|
|
||||||
router.get('/user', (req, res) => {
|
router.get('/user', async (req, res) => {
|
||||||
if (typeof req.query.userID != 'string') {
|
if (typeof req.query.userID != 'string') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ router.get('/user', (req, res) => {
|
||||||
userID = req.session.accountID;
|
userID = req.session.accountID;
|
||||||
}
|
}
|
||||||
|
|
||||||
let user = getUserByID(userID);
|
let user = await getUserByID(userID);
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
res.json({ status: 'success', data: user });
|
res.json({ status: 'success', data: user });
|
||||||
|
|
|
@ -57,8 +57,8 @@ export function getPoolsWithUser(userID: string) {
|
||||||
return poolIDs;
|
return poolIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUserByID(userID: string): Carpool.User | undefined {
|
export async function getUserByID(userID: string) {
|
||||||
return users[userID];
|
return await UserModel.findById(userID).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPoolByID(poolID: string): Carpool.Pool | undefined {
|
export function getPoolByID(poolID: string): Carpool.Pool | undefined {
|
||||||
|
@ -72,7 +72,9 @@ export function getGroupByID(groupID: string): Carpool.Group | undefined {
|
||||||
export async function getUserByEmail(
|
export async function getUserByEmail(
|
||||||
email: string
|
email: string
|
||||||
): Promise<Carpool.User | undefined> {
|
): Promise<Carpool.User | undefined> {
|
||||||
return undefined;
|
return ((await UserModel.findOne({
|
||||||
|
email,
|
||||||
|
}).exec()) as unknown) as Carpool.User;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function registerUserFromIonProfile(
|
export async function registerUserFromIonProfile(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user