Skip to content

Instantly share code, notes, and snippets.

@gausnes
Last active March 17, 2023 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gausnes/4c7ed2ba8929911ddac8906469423b04 to your computer and use it in GitHub Desktop.
Save gausnes/4c7ed2ba8929911ddac8906469423b04 to your computer and use it in GitHub Desktop.
fujinomiya
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);
}
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