-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathidp.ts
37 lines (35 loc) · 960 Bytes
/
idp.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* This `users` object represents what would be the identity provider in a production environment.
*/
export const users = [
{
username: "alice",
password: "supersecret",
role: "admin",
},
{
username: "john",
password: "password1234",
role: "user",
},
{
username: "sarah",
password: "asdfghjkl",
role: "user",
},
{
username: "geri",
password: "pwd123",
role: "user",
},
];
// Here you retrieve the user from your IdP
export async function findUser({ username }: { username: string }) {
return users.find((user) => user.username === username);
}
// Compare the password of an already fetched user (using `findUser`) and compare the
// password for a potential match. We do a simple plain text comparison here for indicative purposes.
export function validatePassword(user: any, inputPassword: string) {
const passwordsMatch = user.password === inputPassword;
return passwordsMatch;
}