Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 8 additions & 3 deletions src/lib/common/ProfileDropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
function logout() {
if (browser){
localStorage.removeItem('user');
}
}
goto('login');
};
</script>
Expand Down Expand Up @@ -39,8 +39,13 @@
/> <span key="t-settings">{$_('Settings')}</span>
</DropdownItem>
<DropdownItem divider />
<DropdownItem href="#" on:click={logout}>
<div>
<DropdownItem href="#">
<div
role="button"
tabindex="0"
on:keydown={() => {}}
on:click={logout}
>
<i class="bx bx-power-off font-size-16 align-middle me-1 text-danger" /> <span>{$_('Logout')}</span>
</div>
</DropdownItem>
Expand Down
7 changes: 6 additions & 1 deletion src/lib/helpers/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ axios.interceptors.response.use(
if (error.response && error.response.status === 401) {
// Perform actions like redirecting to the login page or refreshing tokens
// Example: redirect to the login page
window.location.href = 'login';
const curUrl = window.location.pathname + window.location.search;
let loginUrl = 'login';
if (curUrl) {
loginUrl += `?redirect=${encodeURIComponent(curUrl)}`;
}
window.location.href = loginUrl;
}

// Return the error to the calling function
Expand Down
15 changes: 12 additions & 3 deletions src/routes/(authentication)/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import Headtitle from '$lib/common/HeadTitle.svelte';
import { getToken } from '$lib/services/auth-service.js';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import {
PUBLIC_SERVICE_URL,
PUBLIC_LIVECHAT_HOST,
Expand Down Expand Up @@ -59,7 +60,12 @@
isOpen = true;
msg = 'Authentication success';
status = 'success';
goto('page/dashboard');
const redirectUrl = $page.url.searchParams.get('redirect');
if (redirectUrl) {
window.location.href = decodeURIComponent(redirectUrl);
} else {
goto('page/dashboard');
}
isSubmitting = false;
});
isSubmitting = false;
Expand Down Expand Up @@ -146,8 +152,9 @@
type="button"
id="password-addon"
on:click={() => onPasswordToggle()}
><i id="password-eye-icon" class="mdi mdi-eye-outline" /></Button
>
<i id="password-eye-icon" class="mdi mdi-eye-outline" />
</Button>
</div>
</div>

Expand All @@ -166,8 +173,10 @@
color="primary"
disabled={isSubmitting}
class="waves-effect waves-light"
type="submit">{!isSubmitting ? 'Log In' : 'Log In...'}</Button
type="submit"
>
{!isSubmitting ? 'Log In' : 'Log In...'}
</Button>
</div>

<div class="mt-4 text-center">
Expand Down