-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from CS3219-AY2223S1/FR1.2
Fr1.2
- Loading branch information
Showing
3 changed files
with
18 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
frontend/node_modules/ | ||
user-service/.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
import { createUser } from './repository.js'; | ||
import { createUser, checkUserName } from './repository.js'; | ||
|
||
//need to separate orm functions from repository to decouple business logic from persistence | ||
export async function ormCreateUser(username, password) { | ||
try { | ||
const newUser = await createUser({username, password}); | ||
newUser.save(); | ||
return true; | ||
const exists = await checkUserName(username); | ||
if(!exists){ | ||
const newUser = await createUser({username, password}); | ||
newUser.save(); | ||
return true; | ||
} else { | ||
const err = new Error('ERROR: UserName already exists'); | ||
console.log(err.message); | ||
throw err; | ||
} | ||
} catch (err) { | ||
console.log('ERROR: Could not create new user'); | ||
return { err }; | ||
} | ||
} | ||
|