Skip to content

Instantly share code, notes, and snippets.

@bpesquet
Created February 11, 2021 21:37
Show Gist options
  • Save bpesquet/43b11ff98a31c770a4d0c01321c10488 to your computer and use it in GitHub Desktop.
Save bpesquet/43b11ff98a31c770a4d0c01321c10488 to your computer and use it in GitHub Desktop.
export interface User {
mail: string;
password: string;
nickName: string;
}
class UserService {
users: Array<User> = [
{ mail: "[email protected]", password: "test", nickName: "test" },
{ mail: "[email protected]", password: "admin", nickName: "admin" },
];
authenticate(mail: string, password: string): User | null {
return (
// Search for the first user matching login and password
this.users.find((u) => u.mail === mail && u.password === password) || null
);
}
}
export default new UserService();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment