Skip to content

Commit b3adeb0

Browse files
committed
custom renderer for logout
1 parent 8a39407 commit b3adeb0

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed
Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
import React from "react";
22
import { StaticWebAppsClassName } from "./constants";
33

4-
const Logout = ({ postLogoutRedirect }: { postLogoutRedirect?: string }) => (
5-
<a
6-
href={`/.auth/logout${
7-
postLogoutRedirect
8-
? `?post_logout_redirect_uri=${postLogoutRedirect}`
9-
: ""
10-
}`}
11-
className={`logout ${StaticWebAppsClassName}`}
12-
>
13-
Logout
14-
</a>
15-
);
4+
export type RenderLogoutProps = {
5+
href: string;
6+
className: string;
7+
};
8+
9+
const Logout = ({
10+
postLogoutRedirect,
11+
customRenderer,
12+
}: {
13+
postLogoutRedirect?: string;
14+
customRenderer?: (props: RenderLogoutProps) => JSX.Element;
15+
}) => {
16+
const href = `/.auth/logout${
17+
postLogoutRedirect ? `?post_logout_redirect_uri=${postLogoutRedirect}` : ""
18+
}`;
19+
const className = `logout ${StaticWebAppsClassName}`;
20+
21+
if (customRenderer) {
22+
return customRenderer({ href, className });
23+
}
24+
25+
return (
26+
<a href={href} className={className}>
27+
Logout
28+
</a>
29+
);
30+
};
1631

1732
export { Logout };

0 commit comments

Comments
 (0)