-
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.
passes user to app, and file cleaning
- Loading branch information
Showing
7 changed files
with
95 additions
and
47 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
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,13 @@ | ||
// types.ts | ||
export type Task = { | ||
id: number; | ||
title: string; | ||
description: string; | ||
completed: boolean; | ||
deadline: string; | ||
stakes: string; | ||
}; | ||
|
||
export type Tasks = { | ||
[key: string]: Task; | ||
}; |
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
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 |
---|---|---|
@@ -1,11 +1,27 @@ | ||
const users: {[key: string]: string} = { | ||
John: '123456', | ||
const users = { | ||
User1: { | ||
username: 'John', | ||
password: '123456', | ||
email: '[email protected]', | ||
}, | ||
User2: { | ||
username: 'Jane', | ||
password: 'Janejane', | ||
email: '[email protected]', | ||
}, | ||
}; | ||
|
||
export default function checkCredentials(username: string, password: string) { | ||
if (users.hasOwnProperty(username) && password === users[username]) { | ||
return true; | ||
const lowerCaseUsername = username.toLowerCase(); | ||
const matchingUser = Object.values(users).find( | ||
user => | ||
user.username.toLowerCase() === lowerCaseUsername || | ||
user.email.toLowerCase() === lowerCaseUsername, | ||
); | ||
|
||
if (matchingUser && password === matchingUser.password) { | ||
return matchingUser.username; | ||
} else { | ||
return false; | ||
return null; | ||
} | ||
} |
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