Last active
March 17, 2023 16:19
-
-
Save gausnes/4c7ed2ba8929911ddac8906469423b04 to your computer and use it in GitHub Desktop.
fujinomiya
This file contains hidden or 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
function getByEmail(identifier, callback) { | |
var users = [ | |
{ name: 'John Doe', password: 'thisshouldbeupdated', phone_number: '+12223334444' }, | |
{ name: 'Jane Doe', password: 'thisshouldbeupdated', phone_number: '+98887776666' }, | |
{ name: 'Gray Doe', password: 'thisshouldbeupdated', phone_number: '+45556667777' }, | |
]; | |
const user = users.find(user => user.phone_number === identifier); | |
if(!user) return callback(null); | |
callback(null, user); | |
} |
This file contains hidden or 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
function login(identifier, password, callback) { | |
var users = [ | |
{ name: 'John Doe', password: 'thisshouldbeupdated', phone_number: '+12223334444' }, | |
{ name: 'Jane Doe', password: 'thisshouldbeupdated', phone_number: '+98887776666' }, | |
{ name: 'Gray Doe', password: 'thisshouldbeupdated', phone_number: '+45556667777' }, | |
]; | |
const user = users.find(user => user.phone_number === identifier); | |
if(!user || user.password !== password) return callback(new WrongUsernameOrPasswordError(identifier, "not valid user")); | |
callback(null, { | |
user_id: `asm|${users.indexOf(user)}`, | |
name: user.name, | |
phone_number: user.phone_number | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment