🐛 Fixed sessions (rememberme)

This commit is contained in:
Mawoka
2022-03-05 19:20:23 +01:00
parent 59a6ff8336
commit 19ddff60f0
2 changed files with 26 additions and 20 deletions
+13 -9
View File
@@ -11,16 +11,8 @@
</script>
<script lang='ts'>
//import { rememberme } from '$lib/utils/clientAuth';
/*if (browser) {
rememberme().then((res) => {
if (res) {
window.location.reload();
}
});
}*/
import { navbarVisible } from '$lib/stores';
import { browser } from '$app/env';
navbarVisible.set(true);
@@ -42,6 +34,18 @@
$: passwordEmpty = loginData.password === '';
$: inputValid = !emailEmpty && !passwordEmpty;
const checkRememberMe = async () => {
const res = await fetch('/api/v1/users/token/rememberme');
if (res.status === 200) {
window.location.reload();
}
};
if (browser) {
checkRememberMe();
}
const login = async (): Promise<void> => {
if (emailEmpty || passwordEmpty) {
return;