-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Authentification basé sur des emails (#10)
* Mise en place d'un routing côté client * Mise en place du store et des actions * Taille de la machine du cronjob explicite * Tout est en place pour envoyer un email de connexion
- Loading branch information
1 parent
c32c756
commit 8cdb256
Showing
20 changed files
with
611 additions
and
331 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"jobs": [ | ||
{ | ||
"command": "0 2 * * * node outils/sync-démarches-simplifiées.js" | ||
"command": "0 2 * * * node outils/sync-démarches-simplifiées.js", | ||
"size": "S" | ||
} | ||
] | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const authorizedEmailDomains = new Set([ | ||
'developpement-durable.gouv.fr', | ||
'beta.gouv.fr' | ||
]) |
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,31 @@ | ||
//@ts-check | ||
|
||
import store from '../store.js'; | ||
import remember from 'remember' | ||
|
||
const PITCHOU_SECRET_STORAGE_KEY = 'secret-pitchou' | ||
|
||
export function init(){ | ||
|
||
return remember(PITCHOU_SECRET_STORAGE_KEY) | ||
.then(secret => { | ||
if(secret){ | ||
// @ts-ignore | ||
store.mutations.setSecret(secret) | ||
} | ||
}) | ||
} | ||
|
||
export async function secretFromURL(){ | ||
const secret = new URLSearchParams(location.search).get("secret") | ||
|
||
if(secret){ | ||
const newURL = new URL(location.href) | ||
newURL.searchParams.delete("secret") | ||
|
||
history.replaceState(null, "", newURL) | ||
store.mutations.setSecret(secret) | ||
|
||
return remember(PITCHOU_SECRET_STORAGE_KEY, secret) | ||
} | ||
} |
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,33 @@ | ||
<script> | ||
/** @type {Set<string>} */ | ||
export let authorizedEmailDomains | ||
/** @type {(email: string) => Promise<void>} */ | ||
export let envoiEmailConnexion | ||
let email; | ||
</script> | ||
|
||
|
||
<h1>Connexion par email</h1> | ||
|
||
<p>Saisissez votre adresse email ici et vous recevrez un email avec un lien secret pour vous connecter à Pitchou.</p> | ||
<p>⚠️ Seules les adresses emails venant d'un de ces domaine peuvent recevoir un lien de connexion : | ||
{#each [...authorizedEmailDomains] as authorizedEmailDomain, i} | ||
{#if i !== 0} , {/if} | ||
<code class="hostname">{authorizedEmailDomain}</code> | ||
{/each} | ||
</p> | ||
|
||
<form on:submit|preventDefault={() => envoiEmailConnexion(email)}> | ||
<input autocomplete="email" type="email" bind:value={email}> | ||
<button>Obtenir un lien de connexion par email</button> | ||
</form> | ||
|
||
|
||
<style lang="scss"> | ||
code.hostname{ | ||
white-space: nowrap; | ||
} | ||
</style> |
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.