forked from b00tc4mp/isdi-bootcamp-202405
-
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.
Add several components to library, implement authenticate-user.sh tes…
…t and modified index.js of login b00tc4mp#99
- Loading branch information
Showing
13 changed files
with
104 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
curl -X POST -v http://localhost:8080/users/auth -d '{"username": "tatig", "password":"123123123"}' -H "Content-Type: application/json" |
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
9 changes: 9 additions & 0 deletions
9
staff/tatiana-garcia/project/app/util/extractPayLoadFromToken.js
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,9 @@ | ||
export default token => { | ||
const payloadB64 = token.slice(token.indexOf('.') + 1, token.lastIndexOf('.')) | ||
|
||
const payloadJSON = atob(payloadB64) | ||
|
||
const payload = JSON.parse(payloadJSON) | ||
|
||
return payload | ||
} |
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,37 @@ | ||
function formatTime(date) { | ||
const seconds = Math.round((Date.now() - date.getTime()) / 1000) | ||
|
||
if (seconds < 60) | ||
return seconds + ' second' + (seconds === 1 ? '' : 's') | ||
|
||
const minutes = Math.round(seconds / 60) | ||
|
||
if (minutes < 60) | ||
return minutes + ' minute' + (minutes === 1 ? '' : 's') | ||
|
||
const hours = Math.round(minutes / 60) | ||
|
||
if (hours < 24) | ||
return hours + ' hour' + (hours === 1 ? '' : 's') | ||
|
||
const days = Math.round(hours / 24) | ||
|
||
if (days < 7) | ||
return days + ' day' + (days === 1 ? '' : 's') | ||
|
||
const weeks = Math.round(days / 7) | ||
|
||
if (weeks < 4) | ||
return weeks + ' week' + (weeks === 1 ? '' : 's') | ||
|
||
const months = Math.round(weeks / 4) | ||
|
||
if (months < 12) | ||
return months + ' month' + (months === 1 ? '' : 's') | ||
|
||
const years = Math.round(months / 12) | ||
|
||
return years + ' year' + (years === 1 ? '' : 's') | ||
} | ||
|
||
export default formatTime |
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,17 @@ | ||
import Button from '../library/Button' | ||
import Container from '../library/Container' | ||
import Paragraph from '../library/Paragraph' | ||
|
||
export default function Confirm({ message, onAccept, onCancel }) { | ||
return <> | ||
<Container className="fixed w-screen top-0 h-screen bg-black opacity-60"></Container> | ||
|
||
<Container className="fixed w-screen top-0 h-screen flex items-center justify-center"> | ||
<Container className="p-4 border bg-white flex-col"> | ||
<Paragraph>{message}</Paragraph> | ||
<Button onClick={onCancel}>Cancel</Button> | ||
<Button onClick={onAccept}>Ok</Button> | ||
</Container> | ||
</Container> | ||
</> | ||
} |
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,5 @@ | ||
export default function Form({ children, className = '', ...nextProps }) { | ||
console.debug('Form -> call') | ||
|
||
return <form className={`flex p-[0_.5rem_.5rem_.5rem] gap-2 min-w[80%] mb-[0%] ${className}`} {...nextProps}>{children}</form> | ||
} |
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,3 +1,4 @@ | ||
export default function Heading({ level = 1, children, className = "", ...nextProps }) { | ||
const Tag = `h${level}` | ||
return <Tag className={`${className}`} {...nextProps}>{children}</Tag> | ||
} |
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,5 @@ | ||
export default function Input({ className = '', ...nextProps }) { | ||
console.debug('Input -> call') | ||
|
||
return <input className={`${className}`} {...nextProps} /> | ||
} |
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,5 @@ | ||
export default function Label({ children, ...nextProps }) { | ||
console.debug('Label -> call') | ||
|
||
return <label className="m-0 italic dark:text-white" {...nextProps} >{children}</label> | ||
} |
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,3 @@ | ||
export default function Paragraph({ children, className = '' }) { | ||
return <p className={`m-2 ${className}`}>{children}</p> | ||
} |
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