mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
5870a6097a
* Chore/unit test (#538) * chore: add unit test * chore: add github action for unit test * feat: init firebase * chore: add development secrets * fix: rename auth -> data-services * feat: update blocksuite 0.3.0-alpha.4 (#543) * feat: add requests * feat: optimize swr cache * feat: add Authorization * feat: add confirm-invitation page * feat: add account sdk api and proxy * docs: update contributing (#550) * docs: update contributing * Update CONTRIBUTING.md * Update CONTRIBUTING.md Co-authored-by: ShortCipher5 <me@shortcipher.me> * feat: update api * feat: remove babelrc setting * feat: add create workspace ui * feat: choose workspaces * feat: login modal * feat: authorization api * feat: login status * fix: remove unused variables * feat: login button * fix: lint * fix: workspace id * fix: i18n type error Co-authored-by: MingLiang Wang <mingliangwang0o0@gmail.com> Co-authored-by: ShortCipher5 <me@shortcipher.me>
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { initializeApp } from 'firebase/app';
|
|
import {
|
|
getAuth,
|
|
createUserWithEmailAndPassword,
|
|
signInWithEmailAndPassword,
|
|
GoogleAuthProvider,
|
|
signInWithPopup,
|
|
} from 'firebase/auth';
|
|
import type { User } from 'firebase/auth';
|
|
|
|
/**
|
|
* firebaseConfig reference: https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
|
|
*/
|
|
const app = initializeApp({
|
|
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
|
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
|
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
|
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
|
|
});
|
|
|
|
export const firebaseAuth = getAuth(app);
|
|
|
|
const signUp = (email: string, password: string) => {
|
|
return createUserWithEmailAndPassword(firebaseAuth, email, password);
|
|
};
|
|
|
|
const signIn = (email: string, password: string) => {
|
|
return signInWithEmailAndPassword(firebaseAuth, email, password);
|
|
};
|
|
|
|
const googleAuthProvider = new GoogleAuthProvider();
|
|
export const signInWithGoogle = () => {
|
|
return signInWithPopup(firebaseAuth, googleAuthProvider);
|
|
};
|
|
|
|
export const onAuthStateChanged = (callback: (user: User | null) => void) => {
|
|
firebaseAuth.onAuthStateChanged(callback);
|
|
};
|