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

Supabase User Auth (new branch) #11

Merged
merged 2 commits into from
Oct 8, 2023
Merged
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"],
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',
},
};
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dotenv": "^16.3.1",
"eslint-config-next": "13.5.2",
"next": "13.5.2",
"react": "18.2.0",
"react": "^18.2.0",
"react-dom": "18.2.0",
"styled-components": "^6.0.8"
},
Expand Down
23 changes: 23 additions & 0 deletions src/api/supabase/auth/auth.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable */

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();
};
37 changes: 37 additions & 0 deletions src/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { useState } from 'react';
import Link from 'next/link';
import LoginForm from '../../components/LoginForm';

Expand All @@ -13,6 +14,12 @@ import {
Button,
} from './styles';

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

export default function App() {
return (
<main>
Expand All @@ -32,3 +39,33 @@ export default function App() {
</main>
);
}

export 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>
</>
);
}
2 changes: 1 addition & 1 deletion src/app/login/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import styled, {createGlobalStyle} from 'styled-components';
import styled, { createGlobalStyle } from 'styled-components';

export const GlobalStyle = createGlobalStyle`
body {
Expand Down