Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[auth] Set up user auth flow #8

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
extends: ["@calblueprint/eslint-config-react", "eslint:recommended", "plugin:react/recommended", "plugin:prettier/recommended"],
rules: {
// Add any custom rules here
// Disable the rule that requires React to be in scope -- we don't need this with React 18
'react/react-in-jsx-scope': 'off',
'react/jsx-uses-react': 'off',
},
};
extends: ["@calblueprint/eslint-config-react"],
rules: {
// Add any custom rules here
// Disable the rule that requires React to be in scope -- we don't need this with React 18
'react/react-in-jsx-scope': 'off',
'react/jsx-uses-react': 'off',
},
};
37 changes: 37 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"@calblueprint/prettier-config": "^0.0.1",
"@supabase/auth-helpers-nextjs": "^0.8.1",
"@supabase/supabase-js": "^2.37.0",
"@types/node": "20.6.3",
"@types/react": "18.2.22",
Expand Down
21 changes: 21 additions & 0 deletions src/api/supabase/auth/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import supabase from '../createClient';

export const handleSignUp = async (email: string, password: string) => {
const { data, error } = await supabase.auth.signUp({
email,
password,
});
console.log(error);
};

export const signInWithEmail = async (email: string, password: string) => {
const { data, error } = await supabase.auth.signInWithPassword({
email,
password,
});
console.log(data);
};

export const signOut = async () => {
const { error } = await supabase.auth.signOut();
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
);

export default supabase;
export default supabase;
14 changes: 7 additions & 7 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import './globals.css'
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css';
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';

const inter = Inter({ subsets: ['latin'] })
const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'Shanti Project',
description: 'Application Created by Blueprint',
}
};

export default function RootLayout({
children,
}: {
children: React.ReactNode
children: React.ReactNode;
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
)
);
}
38 changes: 38 additions & 0 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use client';

import { useState } from 'react';
import {
handleSignUp,
signInWithEmail,
signOut,
} from '../../api/supabase/auth/auth';

export default function Login() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');

return (
<>
<input
name="email"
onChange={e => setEmail(e.target.value)}
value={email}
/>
<input
type="password"
name="password"
onChange={e => setPassword(e.target.value)}
value={password}
/>
<button type="button" onClick={() => handleSignUp(email, password)}>
Sign up
</button>
<button type="button" onClick={() => signInWithEmail(email, password)}>
Sign in
</button>
<button type="button" onClick={signOut}>
Sign out
</button>
</>
);
}
95 changes: 0 additions & 95 deletions src/app/page.tsx

This file was deleted.

24 changes: 20 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -19,7 +23,19 @@
}
],
"paths": {
"@/*": ["./src/*"]
}
"@/*": [
"./src/*"
]
},
"forceConsistentCasingInFileNames": true
},
}
"include": [
"next-env.d.ts",
".next/types/**/*.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}