-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
32 lines (29 loc) · 1.12 KB
/
App.js
File metadata and controls
32 lines (29 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { getAuth, createUserWithEmailAndPassword } from "firebase/auth";
import { getFirestore, doc, setDoc } from "firebase/firestore";
export class App {
constructor() {
this.auth = getAuth();
this.db = getFirestore();
}
async register(username, firstname, lastname, email, password, accountType) {
if (password !== confirm_password) {
// Handle the password confirmation logic
return;
}
try {
const userCredential = await createUserWithEmailAndPassword(this.auth, email, password);
const user = userCredential.user;
// Store additional user details in Firestore
await setDoc(doc(this.db, "users", user.uid), {
username: username,
firstname: firstname,
lastname: lastname,
email: email,
accountType: accountType.value // Assuming this is an input element of radio buttons
});
// Handle successful registration
} catch (error) {
// Handle errors, such as email already in use
}
}
}