desktop/machines: liberar handshake e ocultar 'Sair' em sessão de máquina
- middleware: torna /machines/handshake público para permitir criação de sessão de máquina sem login prévio - nav-user: oculta botão 'Encerrar sessão' quando a sessão é de máquina (role === 'machine') Efeito: no app desktop (Tauri), o handshake passa a autenticar corretamente, o cabeçalho exibe nome/e-mail do colaborador/gestor e o portal permite abrir chamados. Nota: em navegação web comum, 'Sair' permanece visível para usuários humanos.
This commit is contained in:
parent
9ac584dcb6
commit
682d39db70
2 changed files with 6 additions and 3 deletions
|
|
@ -2,7 +2,8 @@ import { NextRequest, NextResponse } from "next/server"
|
||||||
import { getCookieCache } from "better-auth/cookies"
|
import { getCookieCache } from "better-auth/cookies"
|
||||||
|
|
||||||
// Rotas públicas explícitas (não autenticadas)
|
// Rotas públicas explícitas (não autenticadas)
|
||||||
const PUBLIC_PATHS = [/^\/login$/]
|
// Permite handshake de máquina sem sessão prévia para criar a sessão de máquina.
|
||||||
|
const PUBLIC_PATHS = [/^\/login$/, /^\/machines\/handshake$/]
|
||||||
// Rotas somente admin
|
// Rotas somente admin
|
||||||
const ADMIN_ONLY_PATHS = [/^\/admin(?:$|\/)/]
|
const ADMIN_ONLY_PATHS = [/^\/admin(?:$|\/)/]
|
||||||
const APP_HOME = "/dashboard"
|
const APP_HOME = "/dashboard"
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import {
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
useSidebar,
|
useSidebar,
|
||||||
} from "@/components/ui/sidebar"
|
} from "@/components/ui/sidebar"
|
||||||
import { signOut } from "@/lib/auth-client"
|
import { signOut, useAuth } from "@/lib/auth-client"
|
||||||
|
|
||||||
type NavUserProps = {
|
type NavUserProps = {
|
||||||
user?: {
|
user?: {
|
||||||
|
|
@ -46,6 +46,8 @@ export function NavUser({ user }: NavUserProps) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [isSigningOut, setIsSigningOut] = useState(false)
|
const [isSigningOut, setIsSigningOut] = useState(false)
|
||||||
const [isDesktopShell, setIsDesktopShell] = useState(false)
|
const [isDesktopShell, setIsDesktopShell] = useState(false)
|
||||||
|
const { session } = useAuth()
|
||||||
|
const isMachineSession = (session?.user?.role ?? "").toLowerCase() === "machine"
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window === "undefined") return
|
if (typeof window === "undefined") return
|
||||||
|
|
@ -141,7 +143,7 @@ export function NavUser({ user }: NavUserProps) {
|
||||||
<span>Notificações (em breve)</span>
|
<span>Notificações (em breve)</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuGroup>
|
</DropdownMenuGroup>
|
||||||
{!isDesktopShell ? (
|
{!isDesktopShell && !isMachineSession ? (
|
||||||
<>
|
<>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue