auth is working yipa

This commit is contained in:
batche
2022-11-12 17:17:06 +01:00
parent 568af62330
commit 8b4545f4d6
140 changed files with 68 additions and 1183 deletions

View File

@@ -1,10 +1,10 @@
FROM node:19-alpine AS development
FROM node:alpine AS development
WORKDIR /usr/src/app
COPY --chown=node:node ./api_front/package*.json ./
RUN npm ci
RUN npm i
COPY --chown=node:node ./api_front/ ./

View File

@@ -2,25 +2,35 @@
import axios from 'axios';
import {push} from 'svelte-spa-router';
let user = {logedIn: false};
$: submit = async() => {
console.log("submit");
const {data} = await axios.get('http://transcendance:8080/api/v2/auth',
{
withCredentials: true,
}
);
if (data.status === "ok") {
push('/');
window.location.href = 'http://transcendance:8080/api/v2/auth';
if (document.cookie) {
user.logedIn = true;
}
}
$: logout = async() => {
fetch('http://transcendance:8080/api/v2/auth/logout');
user.logedIn = false;
}
console.log(user.logedIn);
</script>
<body>
<main class="form-signin w-100 m-auto">
{#if !user.logedIn}
<button on:click={submit} class="w-100 btn btn-lg btn-primary" type="submit">
Connexion avec prout
Connexion
</button>
{/if}
{#if user.logedIn}
<button on:click={logout} class="w-100 btn btn-lg btn-primary" type="submit">
Deconnexion
</button>
{/if}
</main>
</body>

View File

@@ -1,3 +1,8 @@
<script>
let href =
</script>
<body>
<main class="d-flex flex-nowrap">
<h1 class="visually-hidden">Sidebars examples</h1>
@@ -10,13 +15,13 @@
<hr>
<ul class="nav nav-pills flex-column mb-auto">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">
<a href="/pouepouet" class="nav-link active" aria-current="page">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#home"/></svg>
Home
Profil
</a>
</li>
<li>
<a href="#" class="nav-link text-white">
<a href="#" class="nav-link text-white" on:click={color}>
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#speedometer2"/></svg>
Dashboard
</a>
@@ -41,21 +46,6 @@
</li>
</ul>
<hr>
<div class="dropdown">
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<img src="https://github.com/mdo.png" alt="" width="32" height="32" class="rounded-circle me-2">
<strong>mdo</strong>
</a>
<ul class="dropdown-menu dropdown-menu-dark text-small shadow">
<li><a class="dropdown-item" href="#">New Game</a></li>
<li><a class="dropdown-item" href="#">Leaderboard</a></li>
<li><a class="dropdown-item" href="#">Chat</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Profile</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Sign out</a></li>
</ul>
</div>
</div>
</main>
</body>

View File

@@ -0,0 +1,14 @@
<script>
import { onMount } from "svelte";
onMount (async() => {
const response = await fetch('http://transcendance:8080/api/v2/user');
const data = await response.json();
console.log(data);
});
const profile = {
</script>