feat: finished connected mongodb

This commit is contained in:
Rushil Umaretiya 2021-04-10 18:33:24 -04:00
parent ef1fd9d67e
commit 1c48408ecb
No known key found for this signature in database
GPG Key ID: 4E8FAF9C926AF959
3 changed files with 15 additions and 11 deletions

View File

@ -1,5 +1,5 @@
NODE_ENV='dev' NODE_ENV='dev'
APP_PORT=3000 APP_PORT=5000
DB_USER=
DB_PASS=
DB_URL= DB_URL=
ION_CLIENT_ID=
ION_CLIENT_SECRET=

View File

@ -1,5 +1,6 @@
import { v4 } from 'uuid'; import { v4 } from 'uuid';
import { IonProfile } from './auth_ion'; import { IonProfile } from './auth_ion';
import { UserModel } from './models';
/** /**
* Records users by id * Records users by id
@ -77,15 +78,18 @@ export async function getUserByEmail(
export async function registerUserFromIonProfile( export async function registerUserFromIonProfile(
profile: IonProfile profile: IonProfile
): Promise<string> { ): Promise<string> {
const id = v4(); const user = new UserModel({
const user: Carpool.User = { id: v4(),
id,
username: profile.ion_username, username: profile.ion_username,
email: profile.tj_email, email: profile.tj_email,
first_name: profile.first_name, first_name: profile.first_name,
last_name: profile.last_name, last_name: profile.last_name,
}; });
users[id] = user;
user.save(function (err) {
if (err) return console.error(err);
});
console.log('Registered user', user); console.log('Registered user', user);
return id; return user.id;
} }

View File

@ -47,4 +47,4 @@ const PoolSchema: Schema = new Schema({
const PoolModel = model('Pool', PoolSchema); const PoolModel = model('Pool', PoolSchema);
export { UserModel, GroupModel, CommentModel }; export { UserModel, GroupModel, CommentModel, PoolModel };