mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Fix logout for SSO users
This commit is contained in:
@@ -2,7 +2,6 @@ import {useAuth} from "Frontend/util/auth";
|
|||||||
import {GearFine, Question, SignOut, User} from "@phosphor-icons/react";
|
import {GearFine, Question, SignOut, User} from "@phosphor-icons/react";
|
||||||
import {Dropdown, DropdownItem, DropdownMenu, DropdownTrigger} from "@heroui/react";
|
import {Dropdown, DropdownItem, DropdownMenu, DropdownTrigger} from "@heroui/react";
|
||||||
import {useNavigate} from "react-router";
|
import {useNavigate} from "react-router";
|
||||||
import {ConfigEndpoint} from "Frontend/generated/endpoints";
|
|
||||||
import Avatar from "Frontend/components/general/Avatar";
|
import Avatar from "Frontend/components/general/Avatar";
|
||||||
import {CollectionElement} from "@react-types/shared";
|
import {CollectionElement} from "@react-types/shared";
|
||||||
import {isAdmin} from "Frontend/util/utils";
|
import {isAdmin} from "Frontend/util/utils";
|
||||||
@@ -11,14 +10,6 @@ export default function ProfileMenu() {
|
|||||||
const auth = useAuth();
|
const auth = useAuth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
async function logout() {
|
|
||||||
if (auth.state.user?.managedBySso) {
|
|
||||||
window.location.href = (await ConfigEndpoint.getSsoLogoutUrl()) || "/";
|
|
||||||
} else {
|
|
||||||
await auth.logout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const profileMenuItems = [
|
const profileMenuItems = [
|
||||||
{
|
{
|
||||||
label: "My Profile",
|
label: "My Profile",
|
||||||
@@ -39,7 +30,7 @@ export default function ProfileMenu() {
|
|||||||
{
|
{
|
||||||
label: "Sign Out",
|
label: "Sign Out",
|
||||||
icon: <SignOut/>,
|
icon: <SignOut/>,
|
||||||
onClick: logout,
|
onClick: auth.logout,
|
||||||
color: "primary"
|
color: "primary"
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -76,12 +76,14 @@ class SecurityConfig(
|
|||||||
// Not needed since the frontend is served by the backend
|
// Not needed since the frontend is served by the backend
|
||||||
http.cors { cors -> cors.disable() }
|
http.cors { cors -> cors.disable() }
|
||||||
|
|
||||||
http.with(VaadinSecurityConfigurer.vaadin()) { configurer ->
|
|
||||||
// use a custom login view and redirect to root on logout
|
|
||||||
configurer.loginView("/login", "/")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.get(ConfigProperties.SSO.OIDC.Enabled) == true) {
|
if (config.get(ConfigProperties.SSO.OIDC.Enabled) == true) {
|
||||||
|
|
||||||
|
http.with(VaadinSecurityConfigurer.vaadin()) { configurer ->
|
||||||
|
// Redirect to SSO provider on logout
|
||||||
|
configurer.loginView("/login", config.get(ConfigProperties.SSO.OIDC.LogoutUrl))
|
||||||
|
}
|
||||||
|
|
||||||
// Use custom success handler to handle user registration
|
// Use custom success handler to handle user registration
|
||||||
http.oauth2Login { oauth2Login -> oauth2Login.successHandler(ssoAuthenticationSuccessHandler) }
|
http.oauth2Login { oauth2Login -> oauth2Login.successHandler(ssoAuthenticationSuccessHandler) }
|
||||||
// Prevent unnecessary redirects
|
// Prevent unnecessary redirects
|
||||||
@@ -91,6 +93,11 @@ class SecurityConfig(
|
|||||||
http.exceptionHandling { exceptionHandling ->
|
http.exceptionHandling { exceptionHandling ->
|
||||||
exceptionHandling.authenticationEntryPoint(CustomAuthenticationEntryPoint())
|
exceptionHandling.authenticationEntryPoint(CustomAuthenticationEntryPoint())
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Use default Vaadin login URLs
|
||||||
|
http.with(VaadinSecurityConfigurer.vaadin()) { configurer ->
|
||||||
|
configurer.loginView("/login")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("dev" in environment.activeProfiles) {
|
if ("dev" in environment.activeProfiles) {
|
||||||
|
|||||||
Reference in New Issue
Block a user