-
Notifications
You must be signed in to change notification settings - Fork 14
/
auth.tsx
49 lines (49 loc) · 1.21 KB
/
auth.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @enable LuciaAuth
*/
// import { ReactNode } from 'react';
// import { cookies } from 'next/headers';
// import { redirect } from 'next/navigation';
// import {
// AuthProvider,
// authRedirects,
// lucia,
// validateRequest,
// } from '~/lib/auth';
// import { Button } from './ui/button';
//
// export const Login = ({
// provider,
// children = `Sign in with ${provider}`,
// }: {
// provider: AuthProvider;
// children?: ReactNode;
// }) => (
// <Button asChild>
// <a href={`/api/auth/login/${provider}`}>{children}</a>
// </Button>
// );
//
// export const Logout = ({ children = 'Sign out' }: { children?: ReactNode }) => {
// async function logout() {
// 'use server';
// const { session } = await validateRequest();
// if (!session) return { error: 'Unauthorized' };
//
// await lucia.invalidateSession(session.id);
//
// const sessionCookie = lucia.createBlankSessionCookie();
// cookies().set(
// sessionCookie.name,
// sessionCookie.value,
// sessionCookie.attributes
// );
// return redirect(authRedirects.afterLogout);
// }
//
// return (
// <form action={logout}>
// <Button>{children}</Button>
// </form>
// );
// };