Login indication #127
@ -9,6 +9,7 @@ import ovh.herisson.Clyde.Tables.User;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ -30,13 +31,10 @@ public class TokenService {
|
|||||||
new SecureRandom().nextBytes(bytes);
|
new SecureRandom().nextBytes(bytes);
|
||||||
for (int i = 0; i < bytes.length; i++) {
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
bytes[i] = (byte) (((bytes[i]+256)%256 %95+ 32));
|
bytes[i] = (byte) (((bytes[i]+256)%256 %95+ 32));
|
||||||
while ((char)bytes[i] == ';'){
|
|
||||||
bytes[i] = new SecureRandom().generateSeed(1)[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// will never end up in the catch because of the way that SecureRandom.nextBytes is implemented
|
// will never end up in the catch because of the way that SecureRandom.nextBytes is implemented
|
||||||
try {
|
try {
|
||||||
return new String(bytes,"ISO_8859_1");
|
return new String(Base64.getEncoder().encode(bytes),"ISO_8859_1");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import { toast } from 'vue3-toastify';
|
import { toast } from 'vue3-toastify';
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import i18n, { setLang } from './i18n.js'
|
import i18n, { setLang } from './i18n.js'
|
||||||
|
import { isLogged } from '@/rest/Users.js'
|
||||||
|
|
||||||
|
|
||||||
// Liste des apps
|
// Liste des apps
|
||||||
@ -19,6 +20,7 @@
|
|||||||
const currentPath = ref(window.location.hash)
|
const currentPath = ref(window.location.hash)
|
||||||
|
|
||||||
window.addEventListener('hashchange', () => {
|
window.addEventListener('hashchange', () => {
|
||||||
|
Logged.value = isLogged();
|
||||||
currentPath.value = window.location.hash
|
currentPath.value = window.location.hash
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -32,6 +34,8 @@
|
|||||||
const login=ref(i18n("app.login"))
|
const login=ref(i18n("app.login"))
|
||||||
const active=ref(false)
|
const active=ref(false)
|
||||||
|
|
||||||
|
const Logged = ref(isLogged());
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -49,7 +53,7 @@
|
|||||||
</a></li>
|
</a></li>
|
||||||
<li style="float: right;" title=login>
|
<li style="float: right;" title=login>
|
||||||
<a class="icon" href="#/login">
|
<a class="icon" href="#/login">
|
||||||
<div class="fa-solid fa-user" style="margin-top: 7px; margin-bottom: 3px;"></div>
|
<div class="fa-solid fa-user" :style="Logged ? 'color: orange' : 'haha'" style="margin-top: 7px; margin-bottom: 3px; "></div>
|
||||||
</a></li>
|
</a></li>
|
||||||
<li style="float: right;" title=notifications>
|
<li style="float: right;" title=notifications>
|
||||||
<a class="icon" href="#Notifications">
|
<a class="icon" href="#Notifications">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import i18n from '@/i18n.js'
|
import i18n from '@/i18n.js'
|
||||||
import { login , register } from '@/rest/Users.js'
|
import { login , register, disconnect } from '@/rest/Users.js'
|
||||||
import { uploadProfilePicture } from '@/rest/uploads.js'
|
import { uploadProfilePicture } from '@/rest/uploads.js'
|
||||||
|
|
||||||
const loginPage= ref(true)
|
const loginPage= ref(true)
|
||||||
@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
const imageSaved = ref(false)
|
const imageSaved = ref(false)
|
||||||
const ppData = ref(false)
|
const ppData = ref(false)
|
||||||
|
|
||||||
|
disconnect()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
import { restGet, restPost } from './restConsumer.js'
|
import { restGet, restPost } from './restConsumer.js'
|
||||||
|
import { getCookie, setCookie } from '@/utils.js'
|
||||||
|
|
||||||
export async function login(user, pass, exp){
|
export async function login(user, pass, exp){
|
||||||
return restPost("/login", {identifier: user, password: pass, expirationDate: exp});
|
return restPost("/login", {identifier: user, password: pass, expirationDate: exp});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isLogged(){
|
||||||
|
return getCookie("session_token") != ""
|
||||||
|
}
|
||||||
|
|
||||||
|
export function disconnect(){
|
||||||
|
setCookie("session_token", ";expires= Thu, 01 Jan 1970 00:00:01 GMT")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a user (tokenless)
|
* Register a user (tokenless)
|
||||||
*
|
*
|
||||||
|
9
frontend/src/rest/apps.js
Normal file
9
frontend/src/rest/apps.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { restGet } from './restConsumer.js'
|
||||||
|
|
||||||
|
export async function appList(){
|
||||||
|
return restGet("/apps")
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function checkPage(page){
|
||||||
|
return restGet("/apps/" + page)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user