diff --git a/src/Components/Firebase/Firebase.js b/src/Components/Firebase/Firebase.js index 5b0e97ec..2aed5bfb 100644 --- a/src/Components/Firebase/Firebase.js +++ b/src/Components/Firebase/Firebase.js @@ -7,7 +7,8 @@ import { GoogleAuthProvider, GithubAuthProvider, FacebookAuthProvider, - TwitterAuthProvider, // Import TwitterAuthProvider + TwitterAuthProvider, + OAuthProvider, // Import OAuthProvider for Microsoft signInWithPopup, RecaptchaVerifier, signInWithPhoneNumber @@ -31,22 +32,24 @@ const db = getFirestore(firebaseApp); const googleProvider = new GoogleAuthProvider(); const githubProvider = new GithubAuthProvider(); const facebookProvider = new FacebookAuthProvider(); -const twitterProvider = new TwitterAuthProvider(); // Initialize TwitterAuthProvider +const twitterProvider = new TwitterAuthProvider(); +const microsoftProvider = new OAuthProvider('microsoft.com'); // Initialize Microsoft provider const auth = getAuth(firebaseApp); export { auth, signInWithPopup, - githubProvider, googleProvider, + githubProvider, facebookProvider, - twitterProvider, // Export twitterProvider + twitterProvider, + microsoftProvider, // Export Microsoft provider GithubAuthProvider, FacebookAuthProvider, - TwitterAuthProvider, // Export TwitterAuthProvider + TwitterAuthProvider, RecaptchaVerifier, signInWithPhoneNumber }; export { db, analytics, firebaseApp as app }; -export default firebaseApp; +export default firebaseApp; \ No newline at end of file diff --git a/src/Components/Login.js b/src/Components/Login.js index dd693de1..f704306d 100644 --- a/src/Components/Login.js +++ b/src/Components/Login.js @@ -5,14 +5,14 @@ import '@fortawesome/fontawesome-free/css/all.min.css'; import logImg from './Profile/log.svg'; import registerImg from './Profile/register.svg'; import homeIcon from './FreeLancer/homeicon.png'; -import { auth, googleProvider, githubProvider, facebookProvider } from './Firebase/Firebase.js'; +import { auth, googleProvider, githubProvider, facebookProvider, microsoftProvider } from './Firebase/Firebase.js'; import { signInWithPopup, signInWithEmailAndPassword, createUserWithEmailAndPassword, RecaptchaVerifier, signInWithPhoneNumber, - TwitterAuthProvider + TwitterAuthProvider, } from 'firebase/auth'; const LogIn = () => { @@ -74,6 +74,18 @@ const LogIn = () => { } }; + const handleMicrosoftSignIn = async () => { + try { + const result = await signInWithPopup(auth, microsoftProvider); + const user = result.user; + localStorage.setItem('user', JSON.stringify(user)); + console.log('Microsoft sign-in success:', user); + navigate('/'); + } catch (error) { + console.error('Microsoft sign-in error:', error); + } + }; + const handleLogin = async (e) => { e.preventDefault(); const emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; @@ -282,6 +294,9 @@ const LogIn = () => {
Use the form below to get in touch. We attempt to respond to support requests within 1 business day.