File tree Expand file tree Collapse file tree 3 files changed +23
-53
lines changed
basic/src/app/(app)/_components
multiple-auth-collections/src/app/(app)/_components
with-payload-local-strategy/src/app/(app)/_components Expand file tree Collapse file tree 3 files changed +23
-53
lines changed Original file line number Diff line number Diff line change 1- "use client ";
1+ import { signOut } from "@/auth ";
22
3- import type { CollectionSlug } from "payload" ;
4-
5- export function SignOutButton ( {
6- userCollectionSlug = "users" ,
7- } : {
8- userCollectionSlug ?: CollectionSlug ;
9- } ) {
3+ export function SignOutButton ( ) {
104 return (
11- < button
12- type = "button"
13- onClick = { async ( ) => {
14- await fetch ( `/api/${ userCollectionSlug } /logout` , {
15- method : "POST" ,
16- headers : {
17- "Content-Type" : "application/json" ,
18- } ,
19- } ) ;
20- window . location . reload ( ) ;
5+ < form
6+ action = { async ( ) => {
7+ "use server" ;
8+ await signOut ( ) ;
219 } }
2210 >
23- Sign Out
24- </ button >
11+ < button type = "submit" > Sign Out</ button >
12+ </ form >
2513 ) ;
2614}
Original file line number Diff line number Diff line change 1- "use client ";
1+ import { signOut } from "@/auth.customers ";
22
33export function SignOutButton ( ) {
44 return (
5- < button
6- type = "button"
7- onClick = { async ( ) => {
8- await fetch ( `/api/customers/logout` , {
9- method : "POST" ,
10- headers : {
11- "Content-Type" : "application/json" ,
12- } ,
13- } ) ;
14- window . location . reload ( ) ;
5+ < form
6+ action = { async ( ) => {
7+ "use server" ;
8+ await signOut ( ) ;
159 } }
1610 >
17- Sign Out (Customer)
18- </ button >
11+ < button type = "submit" > Sign Out (Customer)</ button >
12+ </ form >
1913 ) ;
2014}
Original file line number Diff line number Diff line change 1- "use client ";
1+ import { signOut } from "@/auth ";
22
3- import type { CollectionSlug } from "payload" ;
4-
5- export function SignOutButton ( {
6- userCollectionSlug = "users" ,
7- } : {
8- userCollectionSlug ?: CollectionSlug ;
9- } ) {
3+ export function SignOutButton ( ) {
104 return (
11- < button
12- type = "button"
13- onClick = { async ( ) => {
14- await fetch ( `/api/${ userCollectionSlug } /logout` , {
15- method : "POST" ,
16- headers : {
17- "Content-Type" : "application/json" ,
18- } ,
19- } ) ;
20- window . location . reload ( ) ;
5+ < form
6+ action = { async ( ) => {
7+ "use server" ;
8+ await signOut ( ) ;
219 } }
2210 >
23- Sign Out
24- </ button >
11+ < button type = "submit" > Sign Out</ button >
12+ </ form >
2513 ) ;
2614}
You can’t perform that action at this time.
0 commit comments