-
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.
* build ./authenticate and ./private points. * use prerequisite extensions to execute authentication logic. * Make simple database.js data store to authenticate user records with. * Apply default authStrategy to ./private point. * No authStrategy for ./authenticate point.
- Loading branch information
Showing
7 changed files
with
200 additions
and
3 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 |
---|---|---|
|
@@ -2,5 +2,6 @@ language: node_js | |
|
||
node_js: | ||
- "8" | ||
- "9" | ||
|
||
sudo: false |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
|
||
// mock user database | ||
|
||
const internals = {}; | ||
|
||
internals.db = [ | ||
{ | ||
'id': 1, | ||
'username': 'foofoo', | ||
'password': '12345678', | ||
'email': 'foo@hapiu.com', | ||
'scope': ['admin', 'user'] | ||
}, | ||
{ | ||
'id': 2, | ||
'username': 'barica', | ||
'password': 'bar', | ||
'email': 'bar@hapiu.com', | ||
'scope': ['user'] | ||
} | ||
]; | ||
|
||
exports.authenticate = (username, password) => { | ||
|
||
for (const userRecord of internals.db) { | ||
|
||
if (userRecord.username === username) { | ||
|
||
// valid username | ||
|
||
if (userRecord.password === password) { | ||
|
||
delete userRecord.password; | ||
|
||
// authentic user credentials | ||
|
||
const authenticUserRecord = { authentic: true, userRecord }; | ||
return authenticUserRecord; | ||
} | ||
|
||
const authenticUserRecord = { authentic: false, userRecord: null }; | ||
return authenticUserRecord; | ||
} | ||
} | ||
|
||
const authenticUserRecord = { authentic: false, userRecord: null }; | ||
return authenticUserRecord; | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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