-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'working' into dev-channel
- Loading branch information
Showing
23 changed files
with
776 additions
and
169 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,96 @@ | ||
|
||
#pop-up-background:has(#A2F-login-form) { | ||
max-width: 435px; | ||
/* padding: 25px; */ | ||
} | ||
|
||
.A2F-login h2 { | ||
font-size: var(--font-size-20); | ||
text-align: center; | ||
padding: 20px; | ||
background-color: rgb(var(--background-color-0), .5); | ||
/* margin-bottom: 20px; */ | ||
} | ||
|
||
.A2F-login .explanation { | ||
color: rgb(var(--text-color-alt)); | ||
padding: 10px 20px; | ||
font-size: var(--font-size-14); | ||
} | ||
|
||
.A2F-login #A2F-login-form { | ||
margin-top: 15px; | ||
} | ||
|
||
.A2F-login h3 { | ||
font-size: var(--font-size-16); | ||
margin-bottom: 25px; | ||
padding-inline: 20px; | ||
text-align: center; | ||
} | ||
|
||
.A2F-login .A2F-answers-container { | ||
display: flex; | ||
flex-flow: column wrap; | ||
gap: 5px 20px; | ||
width: max-content; | ||
align-content: center; | ||
margin-inline: auto; | ||
margin-bottom: 30px; | ||
max-height: 250px; | ||
} | ||
|
||
.A2F-login .A2F-content-loader-container { | ||
display: flex; | ||
flex-flow: row nowrap; | ||
align-items: center; | ||
gap: 5px; | ||
} | ||
|
||
.A2F-login .A2F-error-message { | ||
margin-inline: 20px; | ||
margin-bottom: 20px; | ||
color: rgb(var(--text-color-error)); | ||
text-align: center; | ||
} | ||
|
||
.A2F-login .A2F-buttons { | ||
font-size: var(--font-size-13); | ||
padding: 12px; | ||
background-color: rgb(var(--background-color-0), .5); | ||
|
||
display: flex; | ||
justify-content: space-around; | ||
gap: 10px; | ||
} | ||
|
||
.A2F-login .A2F-buttons > * { | ||
margin: 0; | ||
font-size: var(--font-size-15); | ||
border: none; | ||
border-radius: 10px; | ||
padding: 6px 16px; | ||
border: 2px solid transparent; | ||
} | ||
|
||
.A2F-login .A2F-buttons .cancel-A2F { | ||
color: rgb(var(--text-color-alt)); | ||
} | ||
.A2F-login .A2F-buttons .cancel-A2F:is(:hover, :focus-visible) { | ||
background-color: transparent; | ||
border-color: rgb(var(--text-color-alt)); | ||
} | ||
.A2F-login .A2F-buttons .cancel-A2F:active { | ||
background-color: rgb(var(--text-color-alt), .2); | ||
} | ||
|
||
.A2F-login .A2F-buttons .submit-A2F { | ||
background-color: rgb(var(--border-color-0)); | ||
} | ||
.A2F-login .A2F-buttons .submit-A2F:is(:hover, :focus-visible) { | ||
filter: brightness(1.15); | ||
} | ||
.A2F-login .A2F-buttons .submit-A2F:active { | ||
filter: brightness(0.9); | ||
} | ||
|
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,104 @@ | ||
|
||
import { useState, useEffect } from "react"; | ||
import ContentLoader from "react-content-loader"; | ||
|
||
import "./A2FLogin.css"; | ||
import PopUp from "../generic/PopUps/PopUp"; | ||
import RadioButton from "../generic/UserInputs/RadioButton"; | ||
import { decodeBase64 } from "../../utils/utils"; | ||
import Button from "../generic/UserInputs/Button"; | ||
|
||
export default function A2FLogin({ fetchA2F, ...props }) { | ||
const [A2FForm, setA2FForm] = useState({}); | ||
const [isOpen, setIsOpen] = useState(true); | ||
const [choice, setChoice] = useState(null); | ||
const [errorMessage, setErrorMessage] = useState(null); | ||
|
||
function callback(response) { | ||
setA2FForm(response.data) | ||
} | ||
|
||
useEffect(() => { | ||
const controller = new AbortController(); | ||
if (Object.keys(A2FForm).length < 1) { | ||
fetchA2F({ callback: callback, controller: controller }); | ||
} | ||
|
||
return () => { | ||
controller.abort(); | ||
} | ||
}, []); | ||
|
||
const handleA2FSubmit = (event) => { | ||
const handleA2FError = (response) => { | ||
if (response.message === null || response.code === 550) { | ||
setErrorMessage("Votre compte EcoleDirecte a peut être été bloqué suite à une réponse incorrecte au défi de sécurité. Consultez vos emails pour les instructions de déblocage.") | ||
} else { | ||
setErrorMessage(response.message) | ||
} | ||
} | ||
|
||
event.preventDefault(); | ||
fetchA2F({ method: "post", choice: choice, errorCallback: handleA2FError }); | ||
} | ||
|
||
// JSX | ||
return ( | ||
<PopUp className="A2F-login" externalClosing={!isOpen} {...props}> | ||
<h2>Authentification à deux facteurs</h2> | ||
<p className="explanation">Ce formulaire est une mesure de sécurité mise en place par EcoleDirecte afin de vérifier votre identité.</p> | ||
<form id="A2F-login-form" onSubmit={handleA2FSubmit}> | ||
{A2FForm.question ? <h3>{decodeBase64(A2FForm.question)}</h3> : <h3><ContentLoader | ||
// animate={settings.get("displayMode") === "quality"} | ||
speed={1} | ||
// backgroundColor={actualDisplayTheme === "dark" ? "#63638c" : "#9d9dbd"} | ||
// foregroundColor={actualDisplayTheme === "dark" ? "#7e7eb2" : "#bcbce3"} | ||
backgroundColor="#63638c" | ||
foregroundColor="#7e7eb2" | ||
height="25" | ||
width="300" | ||
> | ||
<rect x="0" y="0" rx="10" ry="10" style={{ width: "100%", height: "100%" }} /> | ||
</ContentLoader></h3>} | ||
{Object.keys(A2FForm).length > 0 | ||
? <div className="A2F-answers-container"> | ||
{A2FForm.propositions.map((answer, index) => <RadioButton id={`A2F-login-${index}`} name="A2F-fieldset" key={answer} data-value={answer} onChange={(event) => setChoice(event.target.dataset.value)}>{decodeBase64(answer)}</RadioButton>)} | ||
</div> | ||
: <div className="A2F-answers-container"> | ||
{Array.from({ length: 11 }, (_, index) => <div className="A2F-content-loader-container" key={crypto.randomUUID()}> | ||
<ContentLoader | ||
// animate={settings.get("displayMode") === "quality"} | ||
speed={1} | ||
// backgroundColor={actualDisplayTheme === "dark" ? "#63638c" : "#9d9dbd"} | ||
// foregroundColor={actualDisplayTheme === "dark" ? "#7e7eb2" : "#bcbce3"} | ||
backgroundColor="#63638c" | ||
foregroundColor="#7e7eb2" | ||
height="20" | ||
width="20" | ||
> | ||
<rect x="0" y="0" rx="10" ry="10" style={{ width: "100%", height: "100%" }} /> | ||
</ContentLoader> | ||
<ContentLoader | ||
// animate={settings.get("displayMode") === "quality"} | ||
speed={1} | ||
// backgroundColor={'#4b48d9'} | ||
// foregroundColor={'#6354ff'} | ||
backgroundColor="#63638c" | ||
foregroundColor="#7e7eb2" | ||
height="25" | ||
width="100" | ||
> | ||
<rect x="0" y="0" rx="10" ry="10" style={{ width: "100%", height: "100%" }} /> | ||
</ContentLoader> | ||
</div>)} | ||
</div> | ||
} | ||
<p className="A2F-error-message">{errorMessage}</p> | ||
<div className="A2F-buttons"> | ||
<Button className="cancel-A2F" onClick={() => setIsOpen(false)}>Annuler</Button> | ||
<Button className="submit-A2F" type="submit">Valider</Button> | ||
</div> | ||
</form> | ||
</PopUp> | ||
); | ||
} |
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
Oops, something went wrong.