Skip to content

Commit

Permalink
Merge pull request #483 from supabase/rc
Browse files Browse the repository at this point in the history
feat: Release V2
  • Loading branch information
alaister authored Oct 11, 2022
2 parents 4e7165e + adfe597 commit eafce05
Show file tree
Hide file tree
Showing 25 changed files with 36,287 additions and 14,219 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:

- run: |
npm ci
npm run v1:docs
npm run v1:docs:json
npm run docs
npm run docs:json
- name: Publish
uses: peaceiris/actions-gh-pages@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ dist

# VisualStudioCode
.vscode/

docs/v2
1 change: 0 additions & 1 deletion docs/v2/.gitkeep

This file was deleted.

34,544 changes: 25,125 additions & 9,419 deletions example/react/package-lock.json

Large diffs are not rendered by default.

47 changes: 34 additions & 13 deletions example/react/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { GoTrueClient } from '@supabase/gotrue-js'
import './tailwind.output.css'

Expand All @@ -9,53 +9,74 @@ const auth = new GoTrueClient({
})

function App() {
let [session, setSession] = useState(auth.session())
let [session, setSession] = useState()
let [email, setEmail] = useState(localStorage.getItem('email') ?? '')
let [phone, setPhone] = useState(localStorage.getItem('phone') ?? '')
let [password, setPassword] = useState('')
let [otp, setOtp] = useState('')
let [rememberMe, setRememberMe] = useState(false)

// Keep the session up to date
auth.onAuthStateChange((_event, session) => setSession(session))
auth.onAuthStateChange((_event, session) => {
setSession(session)
})

useEffect(() => {
async function session() {
const { data, error } = await auth.getSession()
if (error | !data) {
setSession('')
} else {
setSession(data.session)
}
}
session()
}, [])

async function handleOAuthLogin(provider) {
let { error } = await auth.signIn({ provider }, { redirectTo: 'http://localhost:3000/welcome'})
let { error } = await auth.signInWithOAuth({
provider,
options: {
redirectTo: 'http://localhost:3000/welcome',
},
})
if (error) console.log('Error: ', error.message)
}
async function handleVerifyOtp() {
let data = await auth.verifyOTP({ phone: phone, token: otp })
console.log(data)
await auth.verifyOTP({ phone: phone, token: otp, type: 'sms' })
}

async function handleSendOtp() {
let data = await auth.signIn({ phone: phone })
console.log(data)
await auth.signInWithOtp({ phone: phone, type: 'sms' })
}
async function handleEmailSignIn() {
if (rememberMe) {
localStorage.setItem('email', email)
} else {
localStorage.removeItem('email')
}
let { error, user } = await auth.signIn({ email, password })
if (!error && !user) alert('Check your email for the login link!')
let { error, data } = await auth.signInWithPassword({ email, password })
if (!error && !data) alert('Check your email for the login link!')
if (error) console.log('Error: ', error.message)
}
async function handleEmailSignUp() {
let { error } = await auth.signUp({ email, password })
let { error } = await auth.signUp({
email,
password,
options: { emailRedirectTo: 'http://localhost:3000/welcome' },
})
if (error) console.log('Error: ', error.message)
}
async function handleSignOut() {
let { error } = await auth.signOut()
if (error) console.log('Error: ', error.message)
if (error) console.log('Error: ', error)
}
async function forgotPassword() {
var email = prompt('Please enter your email:')
if (email === null || email === '') {
window.alert('You must enter your email.')
} else {
let { error } = await auth.api.resetPasswordForEmail(email)
let { error } = await auth.resetPasswordForEmail(email)
if (error) {
console.log('Error: ', error.message)
} else {
Expand Down
Loading

0 comments on commit eafce05

Please sign in to comment.