diff --git a/src/auth_ion.ts b/src/auth_ion.ts index 54b3764..74a07cd 100644 --- a/src/auth_ion.ts +++ b/src/auth_ion.ts @@ -92,6 +92,6 @@ export async function getAccountIDFromIonCode(code: string) { if (user == null) { return await registerUserFromIonProfile(profile); } else { - return user.id; + return user.uuid; } } diff --git a/src/data.ts b/src/data.ts index 9a57bab..75aaaf2 100644 --- a/src/data.ts +++ b/src/data.ts @@ -7,7 +7,7 @@ import { UserModel } from './models'; */ export const users: Record = { myfatemi04: { - id: '3baeaed6-05cb-4c03-9b43-1d74beafdbb7', + uuid: '3baeaed6-05cb-4c03-9b43-1d74beafdbb7', email: '2022mfatemi@tjhsst.edu', username: 'myfatemi04', first_name: 'Michael', @@ -72,16 +72,18 @@ export function getGroupByID(groupID: string): Carpool.Group | undefined { export async function getUserByEmail( email: string ): Promise { - return ((await UserModel.findOne({ - email, - }).exec()) as unknown) as Carpool.User; + return (( + await UserModel.findOne({ + email, + }).exec() + ).toJSON() as unknown) as Carpool.User; } export async function registerUserFromIonProfile( profile: IonProfile ): Promise { const user = new UserModel({ - id: v4(), + uuid: v4(), username: profile.ion_username, email: profile.tj_email, first_name: profile.first_name, diff --git a/src/models.ts b/src/models.ts index f6b9308..900e581 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,6 +1,7 @@ import { model, Schema } from 'mongoose'; const UserSchema: Schema = new Schema({ + uuid: { type: String, required: true }, email: { type: String, required: true }, username: { type: String, required: true }, first_name: { type: String, required: true }, diff --git a/src/types.ts b/src/types.ts index 437f2a3..a1c2f08 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,7 +5,7 @@ namespace Carpool { } export interface User { - id: string; + uuid: string; email: string; username: string; first_name: string;