Reputation: 621
Thought I would take supabase for a spin over the holidays, simple to setup but I have hit a snag with email authentication.
I copy pasted the signUp()
block from [the docs][1], but I'm unable to log out data on signup success. I am able to log the errors without effort when for instance, I try to signup with an existing email. I have validated that the registration data is being recorded in supabase accurately. I also checked the network tab & can see the access token and response there, but not from a console.log.
Hoping that there is something minor I've been overlooking, should I be checking for a session after signup?
I'm using supabase v2.0 & vuejs3/vite with the options API & pinia as my store
Here is the relevant code:
RegistrationView.vue
methods: {
async handleRegistration() {
const { data, error } = await supabase.auth.signUp({
email: this.email,
password: this.password,
options: {
data: {
firstName: this.firstName,
lastName: this.lastName,
phone: this.phone,
},
},
});
if (error) {
console.log({ error });
}
if (data) {
console.log({ data });
}
},
},
Solved: TLDR;
Don't destruct data
from signup(), descruct error
, user
& session
instead.
i.e.
const { error, session, user } = await supabase.auth.signUp({
.
.
.
})
Upvotes: 2
Views: 2249
Reputation: 18612
signUp()
will always return either data or error, so you should always see one or the other in your console.
What you are looking for should be contained inside data.session
and data.user
.
Upvotes: 2