Fix connection through Kerberos
Some checks are pending
continuous-integration/drone/push Build is running

This commit is contained in:
nemunaire 2022-09-07 20:54:04 +02:00
parent b572938283
commit 60540a1631
2 changed files with 30 additions and 22 deletions

View File

@ -80,5 +80,10 @@ func checkAuthKrb5(c *gin.Context) {
return return
} }
completeAuth(c, lf.Login, lf.Login+"@epita.fr", "", "", "", nil) if usr, err := completeAuth(c, lf.Login, lf.Login+"@epita.fr", "", "", "", nil); err != nil {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"errmsg": err.Error()})
return
} else {
c.JSON(http.StatusOK, authToken{User: usr, CurrentPromo: currentPromo})
}
} }

View File

@ -3,6 +3,7 @@
import { page } from '$app/stores' import { page } from '$app/stores'
import AuthButton from '../components/AuthButton.svelte'; import AuthButton from '../components/AuthButton.svelte';
import { ToastsStore } from '../stores/toasts';
import { user } from '../stores/user'; import { user } from '../stores/user';
let auth = { username: "", password: "" }; let auth = { username: "", password: "" };
@ -17,23 +18,25 @@
body: JSON.stringify(auth), body: JSON.stringify(auth),
}) })
.then((response) => { .then((response) => {
response.json().then((auth) => { if (response.status == 200) {
response.json().then((auth) => {
pleaseWait = false;
if (next && next.indexOf('//') === -1) {
goto(next)
} else {
goto(".");
}
})
} else {
pleaseWait = false; pleaseWait = false;
if (next && next.indexOf('//') === -1) { response.json().then((data) => {
goto(next) ToastsStore.addToast({
} else { color: "danger",
goto("."); title: "Connexion impossible",
} msg: (data ? data.errmsg : "Impossible de contacter le serveur"),
}) });
}) });
.catch((response) => { }
pleaseWait = false;
if (response.data)
ToastsStore.addToast({
color: "danger",
title: "Connexion impossible",
msg: (response.data ? response.data.errmsg : "Impossible de contacter le serveur"),
});
}); });
} }
@ -51,13 +54,13 @@
<div class="row"> <div class="row">
<form class="col" on:submit|preventDefault={logmein}> <form class="col" on:submit|preventDefault={logmein}>
<h2>Accès à votre compte</h2> <h2>Accès à votre compte</h2>
<div class="mb-3"> <div class="form-floating mb-3">
<label for="login" class="form-label">CRI login</label> <input type="text" class="form-control" id="login" bind:value={auth.username} placeholder="xavier.login" autofocus>
<input class="form-control" id="login" bind:value={auth.username} placeholder="Entrer votre login" autofocus> <label for="login">CRI login</label>
</div> </div>
<div class="mb-3"> <div class="form-floating mb-3">
<label for="password" class="form-label">Mot de passe</label>
<input type="password" class="form-control" id="password" bind:value={auth.password} placeholder="Mot de passe"> <input type="password" class="form-control" id="password" bind:value={auth.password} placeholder="Mot de passe">
<label for="password">Mot de passe</label>
</div> </div>
<button type="submit" class="btn btn-info"> <button type="submit" class="btn btn-info">
{#if pleaseWait} {#if pleaseWait}