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