Skip to content

Commit 6ac118d

Browse files
committed
fix: logout bug by passing logoutParams
1 parent 58f7ea0 commit 6ac118d

File tree

8 files changed

+31
-12
lines changed

8 files changed

+31
-12
lines changed

examples/spa/src/components/LogoutButton.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useState } from "react";
22
import { useFastAuth } from "../hooks/use-fast-auth-relayer";
33
import Spinner from "./Spinner";
4+
import {FastAuthClient} from "@fast-auth/browser-sdk";
5+
import {JavascriptProvider} from "@fast-auth/javascript-provider";
46

57
export function LogoutButton() {
68
const { client } = useFastAuth();
@@ -9,7 +11,11 @@ export function LogoutButton() {
911
const handleLogout = async () => {
1012
setIsLoading(true);
1113
try {
12-
await client?.logout();
14+
await (client as FastAuthClient<JavascriptProvider>)?.logout({
15+
logoutParams: {
16+
returnTo: window.location.origin,
17+
}
18+
});
1319
} finally {
1420
setIsLoading(false);
1521
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { SignatureRequest } from "../signer/types";
22

3-
export interface IFastAuthProvider {
3+
export interface ISignerFastAuthProvider {
44
isLoggedIn(): Promise<boolean>;
55
requestTransactionSignature(...args: any[]): Promise<void>;
66
requestDelegateActionSignature(...args: any[]): Promise<void>;
77
getSignatureRequest(): Promise<SignatureRequest>;
88
getPath(): Promise<string>;
99
}
10+
11+
export interface IFastAuthProvider extends ISignerFastAuthProvider {
12+
login(...args: any[]): void;
13+
logout(...args: any[]): void;
14+
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { SignatureRequest } from "../signer/types";
22

3-
export interface IFastAuthProvider {
3+
export interface ISignerFastAuthProvider {
44
isLoggedIn(): Promise<boolean>;
55
requestTransactionSignature(...args: any[]): Promise<void>;
66
requestDelegateActionSignature(...args: any[]): Promise<void>;
77
getSignatureRequest(): Promise<SignatureRequest>;
88
getPath(): Promise<string>;
99
}
10+
11+
export interface IFastAuthProvider extends ISignerFastAuthProvider {
12+
login(...args: any[]): void;
13+
logout(...args: any[]): void;
14+
}

packages/providers/javascript/src/provider.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Auth0Client } from "@auth0/auth0-spa-js";
1+
import { Auth0Client, LogoutOptions } from "@auth0/auth0-spa-js";
22
import {
33
JavascriptProviderOptions,
44
JavascriptBaseRequestDelegateActionSignatureOptions,
@@ -126,9 +126,10 @@ export class JavascriptProvider implements IFastAuthProvider {
126126

127127
/**
128128
* Log out of the client.
129+
* @param options
129130
*/
130-
async logout(): Promise<void> {
131-
await this.client.logout();
131+
async logout(options?: LogoutOptions): Promise<void> {
132+
await this.client.logout(options);
132133
}
133134

134135
/**

packages/sdks/browser/src/client/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ export class FastAuthClient<P extends IFastAuthProvider = IFastAuthProvider> {
2828

2929
/**
3030
* Log out of the client.
31+
* @param args The arguments for the logout.
3132
* @returns The signature request.
3233
*/
33-
logout() {
34-
return this.provider.logout();
34+
logout(...args: Parameters<P["logout"]>) {
35+
return this.provider.logout(args);
3536
}
3637

3738
/**

packages/sdks/browser/src/client/providers/fast-auth.provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { IFastAuthProvider as ISignerFastAuthProvider } from "../../signers/prov
22

33
export interface IFastAuthProvider extends ISignerFastAuthProvider {
44
login(...args: any[]): void;
5-
logout(): void;
5+
logout(...args: any[]): void;
66
}

packages/sdks/react/src/core/client/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ export class FastAuthClient<P extends IFastAuthProvider = IFastAuthProvider> {
3434

3535
/**
3636
* Log out of the client.
37+
* @param args The arguments for the logout.
3738
* @returns The signature request.
3839
*/
39-
logout() {
40-
return this.provider.logout();
40+
logout(...args: Parameters<P["logout"]>[]) {
41+
return this.provider.logout(args);
4142
}
4243

4344
/**

packages/sdks/react/src/core/client/providers/fast-auth.provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { IFastAuthProvider as ISignerFastAuthProvider } from "../../signers/prov
22

33
export interface IFastAuthProvider extends ISignerFastAuthProvider {
44
login(...args: any[]): void;
5-
logout(): void;
5+
logout(...args: any[]): void;
66
}

0 commit comments

Comments
 (0)