Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Migration ProConnect #460

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/app.postcss

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions src/lib/components/specialized/pc-button.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script lang="ts">
import { getApiURL } from "$lib/utils/api";

export let nextPage: string;

const loginUrl =
getApiURL() + "/oidc/login/?next=" + encodeURIComponent(nextPage);
</script>

<div class="text-center">
<a class="mb-s24 inline-block" href={loginUrl}>
<div
class="proconnect-button mx-auto mt-s24 flex items-center justify-center rounded-full bg-france-blue p-s6 pr-s24 text-f16 text-white transition-colors hover:bg-[#2323FF]"
></div>
</a>

<div class="text-center">
<a
class="text-magenta-cta underline"
target="_blank"
title="Ouverture dans une nouvelle fenêtre"
rel="noopener"
href="https://aide.dora.inclusion.beta.gouv.fr"
>
Besoin d’aide&nbsp;? Contactez-nous (mais pas tout de suite)
</a>
</div>
</div>
11 changes: 10 additions & 1 deletion src/routes/_index/menu-mon-compte.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@
<span class="mr-s10 inline-block h-s24 w-s24 fill-current" aria-hidden>
{@html logoutBoxLineIcon}
</span>
Déconnexion
Déconnexion (IC)
</a>

<hr />

<a href="/auth/pc-logout" class={aClass}>
<span class="mr-s10 inline-block h-s24 w-s24 fill-current" aria-hidden>
{@html logoutBoxLineIcon}
</span>
Déconnexion (PC)
</a>
</DropdownMenu>
2 changes: 2 additions & 0 deletions src/routes/auth/connexion/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import CenteredGrid from "$lib/components/display/centered-grid.svelte";
import Breadcrumb from "$lib/components/display/breadcrumb.svelte";
import IcButton from "$lib/components/specialized/ic-button.svelte";
import PcButton from "$lib/components/specialized/pc-button.svelte";

function getLoginHint() {
const loginHint = $page.url.searchParams.get("login_hint");
Expand Down Expand Up @@ -62,6 +63,7 @@
</div>

<IcButton {nextPage} {loginHint}></IcButton>
<PcButton {nextPage} {loginHint}></PcButton>
</div>
</FieldSet>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/routes/auth/ic-callback/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export const load: PageLoad = async ({ url, parent }) => {
window.localStorage.removeItem("oidcState");

const targetUrl = `${getApiURL()}/inclusion-connect-authenticate/`;
// ce call retourne une structure avec le token DRF initialisé coté backend

const result = await fetch(targetUrl, {
method: "POST",
headers: {
Expand Down
2 changes: 2 additions & 0 deletions src/routes/auth/pc-callback/+page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const ssr = false;
export const load = () => {};
12 changes: 12 additions & 0 deletions src/routes/auth/pc-callback/[token]/+page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { CANONICAL_URL } from "$lib/env";
import { setToken } from "$lib/utils/auth";
import { redirect } from "@sveltejs/kit";
import { getNextPage } from "../../utils";

export const load = ({ params, url }) => {
const token = params.token;
setToken(token);

// home pour l'instant
redirect(302, CANONICAL_URL + getNextPage(url));
};
8 changes: 8 additions & 0 deletions src/routes/auth/pc-logout/+page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getApiURL } from "$lib/utils/api";
import { disconnect } from "$lib/utils/auth";
import { redirect } from "@sveltejs/kit";

export const load = () => {
disconnect();
redirect(302, getApiURL() + "/oidc/pre_logout/");
};
Loading