@@ -9,12 +9,10 @@ import {
9
9
createUserWithEmailAndPassword ,
10
10
sendPasswordResetEmail ,
11
11
updatePassword ,
12
- linkWithPopup
13
- }
14
- from 'firebase/auth' ;
15
-
16
- import { getFirestore , doc , setDoc , getDoc } from 'firebase/firestore' ;
12
+ linkWithPopup ,
13
+ } from "firebase/auth" ;
17
14
15
+ import { getFirestore , doc , setDoc , getDoc } from "firebase/firestore" ;
18
16
19
17
// TODO: Add SDKs for Firebase products that you want to use
20
18
// https://firebase.google.com/docs/web/setup#available-libraries
@@ -49,31 +47,35 @@ const googleProvider = new GoogleAuthProvider();
49
47
const signInWithGoogle = ( ) => signInWithPopup ( auth , googleProvider ) ;
50
48
51
49
const linkWithGoogle = async ( ) => {
52
- const user = auth . currentUser ;
53
- await linkWithPopup ( user , googleProvider ) ;
50
+ const user = auth . currentUser ;
51
+ await linkWithPopup ( user , googleProvider ) ;
54
52
} ;
55
53
56
54
const registerWithEmail = async ( email , password ) => {
57
- const userCredential = await createUserWithEmailAndPassword ( auth , email , password ) ;
58
- const user = userCredential . user ;
59
- await setDoc ( doc ( db , "users" , user . uid ) , {
60
- email : user . email ,
61
- enrolled : false ,
62
- course : "AI Innovate Scholars" ,
63
- } ) ;
55
+ const userCredential = await createUserWithEmailAndPassword (
56
+ auth ,
57
+ email ,
58
+ password
59
+ ) ;
60
+ const user = userCredential . user ;
61
+ await setDoc ( doc ( db , "users" , user . uid ) , {
62
+ email : user . email ,
63
+ enrolled : false ,
64
+ course : "AI Innovate Scholars" ,
65
+ } ) ;
64
66
} ;
65
-
67
+
66
68
const signInWithEmailAndPassword = async ( email , password ) => {
67
69
await firebaseSignInWithEmailAndPassword ( auth , email , password ) ;
68
70
} ;
69
71
70
72
const sendPasswordReset = async ( email ) => {
71
- await sendPasswordResetEmail ( auth , email ) ;
73
+ await sendPasswordResetEmail ( auth , email ) ;
72
74
} ;
73
-
75
+
74
76
const changePassword = async ( password ) => {
75
- const user = auth . currentUser ;
76
- await updatePassword ( user , password ) ;
77
+ const user = auth . currentUser ;
78
+ await updatePassword ( user , password ) ;
77
79
} ;
78
80
const signInWithDiscord = ( ) => {
79
81
window . location . href = `https://discord.com/api/oauth2/authorize?client_id=${ import . meta. env . VITE_DISCORD_CLIENT_ID } &redirect_uri=${ import . meta. env . VITE_DISCORD_REDIRECT_URI } &response_type=code&scope=identify email` ;
@@ -82,7 +84,6 @@ const signInWithDiscord = () => {
82
84
const linkWithDiscord = ( ) => {
83
85
window . location . href = `https://discord.com/api/oauth2/authorize?client_id=${ import . meta. env . VITE_DISCORD_CLIENT_ID } &redirect_uri=${ import . meta. env . VITE_DISCORD_REDIRECT_URI } &response_type=code&scope=identify email` ;
84
86
} ;
85
-
86
87
87
88
// const handleDiscordCallback = async (code) => {
88
89
// const { data } = await axios.post('https://discord.com/api/oauth2/token', null, {
@@ -97,25 +98,25 @@ const linkWithDiscord = () => {
97
98
// 'Content-Type': 'application/x-www-form-urlencoded',
98
99
// },
99
100
// });
100
-
101
+
101
102
// const user = await axios.get('https://discord.com/api/users/@me', {
102
103
// headers: {
103
104
// Authorization: `Bearer ${data.access_token}`,
104
105
// },
105
106
// });
106
-
107
+
107
108
// // Handle user data and authentication in your app
108
109
// };
109
110
110
111
export {
111
- auth ,
112
- db ,
113
- signInWithGoogle ,
114
- signInWithDiscord ,
115
- signInWithEmailAndPassword ,
116
- registerWithEmail ,
117
- sendPasswordResetEmail ,
118
- updatePassword ,
119
- linkWithGoogle ,
120
- linkWithDiscord
121
- } ;
112
+ auth ,
113
+ db ,
114
+ signInWithGoogle ,
115
+ signInWithDiscord ,
116
+ signInWithEmailAndPassword ,
117
+ registerWithEmail ,
118
+ sendPasswordResetEmail ,
119
+ updatePassword ,
120
+ linkWithGoogle ,
121
+ linkWithDiscord ,
122
+ } ;
0 commit comments