diff options
Diffstat (limited to 'frontend/components/AuthButton.tsx')
| -rw-r--r-- | frontend/components/AuthButton.tsx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/frontend/components/AuthButton.tsx b/frontend/components/AuthButton.tsx new file mode 100644 index 0000000..05c493c --- /dev/null +++ b/frontend/components/AuthButton.tsx | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | import { Auth_get_user, Auth_tinyauth_public_endpoint } from '@/lib/auth' | ||
| 2 | |||
| 3 | export default async function AuthButton() { | ||
| 4 | const user = await Auth_get_user() | ||
| 5 | const authEndpoint = Auth_tinyauth_public_endpoint() | ||
| 6 | |||
| 7 | if (user.isLoggedIn) { | ||
| 8 | return ( | ||
| 9 | <div className="flex items-center gap-4"> | ||
| 10 | <span className="text-sm text-gray-600 dark:text-gray-300"> | ||
| 11 | {user.email} | ||
| 12 | </span> | ||
| 13 | <a | ||
| 14 | href={authEndpoint} | ||
| 15 | className="px-3 py-1 text-sm bg-red-600 hover:bg-red-700 text-white rounded transition-colors" | ||
| 16 | > | ||
| 17 | Logout | ||
| 18 | </a> | ||
| 19 | </div> | ||
| 20 | ) | ||
| 21 | } | ||
| 22 | |||
| 23 | return ( | ||
| 24 | <a | ||
| 25 | href={authEndpoint} | ||
| 26 | className="px-3 py-1 text-sm bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors" | ||
| 27 | > | ||
| 28 | Login | ||
| 29 | </a> | ||
| 30 | ) | ||
| 31 | } \ No newline at end of file | ||
