Skip to content

Commit

Permalink
gg
Browse files Browse the repository at this point in the history
  • Loading branch information
upayanmazumder committed Nov 29, 2024
1 parent e127e19 commit 985fd97
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions app/src/components/auth/signup/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,30 @@ const Signup = () => {
setSuccess(false);

try {
// Step 1: Create user with Firebase Auth
const userCredential = await createUserWithEmailAndPassword(auth, email, password);
console.log('User signed up:', userCredential.user);
setSuccess(true);

// Step 2: Send request to your API to update Firebase database
const response = await fetch('https://api.cas.upayan.dev/auth/signup', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: userCredential.user.email,
password: password, // You may choose not to send password if not required
}),
});

const data = await response.json();

if (response.ok) {
setSuccess(true);
console.log('User data updated in Firebase:', data);
} else {
setError(data.error || 'Failed to update user data');
}
} catch (err) {
console.error('Error signing up:', err);
setError(err.message);
Expand Down Expand Up @@ -51,4 +72,4 @@ const Signup = () => {
);
};

export default Signup;
export default Signup;

0 comments on commit 985fd97

Please sign in to comment.