mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Fix #1304 , Define the defualt behavior of signUp
- Updated auth example to handle this. - signUp function now gives error if the user is already registered. - signIn function gives error when invalid email or password is entered.
This commit is contained in:
1 parent
776a1d2ab8
commit
35a3164647
2 files changed
+10
-13
No files matched your search
@@ -1,4 +1,3 @@
|
||||
|
||||
var SUPABASE_URL = 'https://ernhobnpmmupjnmxpfbt.supabase.co'
|
||||
var SUPABASE_KEY =
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYxMzA5ODU0NCwiZXhwIjoxOTI4Njc0NTQ0fQ.Z9bRrfaL2oGhSuyBckFcdcnRIJDelWJ1II98OnEtLO0'
|
||||
@@ -26,11 +25,9 @@ const signUpSubmitted = (event) => {
|
||||
const password = event.target[1].value
|
||||
|
||||
supabase.auth
|
||||
.signUp({email, password})
|
||||
.signUp({ email, password })
|
||||
.then((response) => {
|
||||
document.querySelector('#access-token').value = response.data.access_token
|
||||
document.querySelector('#refresh-token').value = response.data.refresh_token
|
||||
alert("Logged in as " + response.user.email)
|
||||
response.error ? alert(response.error.message) : alert('Confirmation Email Sent')
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(err.response.text)
|
||||
@@ -43,12 +40,13 @@ const logInSubmitted = (event) => {
|
||||
const password = event.target[1].value
|
||||
|
||||
supabase.auth
|
||||
.signIn({email, password})
|
||||
.signIn({ email, password })
|
||||
.then((response) => {
|
||||
document.querySelector('#access-token').value = response.data.access_token
|
||||
response.error
|
||||
? alert(response.error.message)
|
||||
: (document.querySelector('#access-token').value = response.data.access_token)
|
||||
document.querySelector('#refresh-token').value = response.data.refresh_token
|
||||
// response.error ?
|
||||
alert("Logged in as " + response.user.email)
|
||||
alert('Logged in as ' + response.user.email)
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(err.response.text)
|
||||
@@ -56,10 +54,9 @@ const logInSubmitted = (event) => {
|
||||
}
|
||||
|
||||
const fetchUserDetails = () => {
|
||||
alert(JSON.stringify(supabase.auth.user()))
|
||||
alert(JSON.stringify(supabase.auth.user()))
|
||||
}
|
||||
|
||||
|
||||
const logoutSubmitted = (event) => {
|
||||
event.preventDefault()
|
||||
|
||||
@@ -68,7 +65,7 @@ const logoutSubmitted = (event) => {
|
||||
.then((response) => {
|
||||
document.querySelector('#access-token').value = ''
|
||||
document.querySelector('#refresh-token').value = ''
|
||||
alert("Logout successful")
|
||||
alert('Logout successful')
|
||||
})
|
||||
.catch((err) => {
|
||||
alert(err.response.text)
|
||||
|
||||
Reference in new issue
Block a user