feat(auth): refactor sign-out functionality and update import paths
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { auth, signOut } from '../auth';
|
import { auth } from '../auth';
|
||||||
|
import { signOutAction } from './actions/auth-actions';
|
||||||
|
|
||||||
const linkStyle: React.CSSProperties = {
|
const linkStyle: React.CSSProperties = {
|
||||||
padding: '0.5rem 0.75rem',
|
padding: '0.5rem 0.75rem',
|
||||||
@@ -41,12 +42,7 @@ export default async function Navigation() {
|
|||||||
<span style={{ fontSize: '0.9rem', color: '#555' }}>
|
<span style={{ fontSize: '0.9rem', color: '#555' }}>
|
||||||
👤 {session.user.name}
|
👤 {session.user.name}
|
||||||
</span>
|
</span>
|
||||||
<form
|
<form action={signOutAction}>
|
||||||
action={async () => {
|
|
||||||
'use server';
|
|
||||||
await signOut({ redirectTo: '/login' });
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
'use server';
|
||||||
|
|
||||||
|
import { signOut } from '../../auth';
|
||||||
|
|
||||||
|
export async function signOutAction() {
|
||||||
|
await signOut({ redirectTo: '/login' });
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { auth } from '../../auth';
|
import { auth } from '../auth';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returnerar Authorization-header med JWT från sessionen.
|
* Returnerar Authorization-header med JWT från sessionen.
|
||||||
|
|||||||
Reference in New Issue
Block a user