Update commit based on feedback

This commit is contained in:
Gaurav Singh committed 2021-05-02 19:25:35 +05:30
1 parent 35a3164647
commit 90f424629f
2 files changed
+14 -7

No files matched your search

+12 -6
View File
@@ -27,7 +27,7 @@ const signUpSubmitted = (event) => {
supabase.auth
.signUp({ email, password })
.then((response) => {
response.error ? alert(response.error.message) : alert('Confirmation Email Sent')
response.error ? alert(response.error.message) : setToken(response)
})
.catch((err) => {
alert(err.response.text)
@@ -42,11 +42,7 @@ const logInSubmitted = (event) => {
supabase.auth
.signIn({ email, password })
.then((response) => {
response.error
? alert(response.error.message)
: (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) : setToken(response)
})
.catch((err) => {
alert(err.response.text)
@@ -71,3 +67,13 @@ const logoutSubmitted = (event) => {
alert(err.response.text)
})
}
function setToken(response) {
if (response.data.confirmation_sent_at && !response.data.access_token) {
alert('Confirmation Email Sent')
} else {
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)
}
}
+2 -1
View File
@@ -14,7 +14,8 @@ The [Supabase Client](/docs/reference/javascript/supabase-client) makes it simpl
## Auth
Create new users using [`signUp()`](/docs/reference/javascript/auth-signup). By default, the user will need to verify their email address before logging in.
Create new users using [`signUp()`](/docs/reference/javascript/auth-signup). By default, the user will need to verify their email address before logging in.<br/>
If confirmations are disabled the response will contain an access token and also a confirmed_at value, otherwise it will just contain a confirmation_sent_at attribute.
<Tabs
groupId="libraries"