rodydavis / fb_auth

Shared Mobile and Web Firebase Login
MIT License
46 stars 11 forks source link

Buy Me A Coffee Donate

fb_auth

A Shared Firebase Auth Plugin for Mobile, Web and Desktop. Included AuthBloc for minimal setup! Single dynamic import and compile time ready for ios, android, macos, windows, linux and web.

This package is now deprecated and was originally created to add firebase on the desktop and web. You can now use the FlutterFire packages to do anything this plugin could.

Getting Started

Setup your Bloc

final _auth = AuthBloc();

Follow Installation Instructions for Web: https://pub.dev/packages/firebase

Update /web/index.html in the body tag.

<!-- The core Firebase JS SDK is always required and must be listed first -->
  <script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-app.js"></script>

  <!-- TODO: Add SDKs for Firebase products that you want to use
      https://firebase.google.com/docs/web/setup#config-web-app -->
  <script src="https://www.gstatic.com/firebasejs//6.3.3/firebase-auth.js"></script>
  <script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-firestore.js"></script>
  <script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-storage.js"></script>
  <script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-functions.js"></script>

  <script>
    // Your web app's Firebase configuration
    var firebaseConfig = {
      apiKey: "API_KEY",
      authDomain: "AUTH_DOMAIN",
      databaseURL: "DATABASE_URL",
      projectId: "PROJECT_ID",
      storageBucket: "STORAGE_BUCKET",
      messagingSenderId: "MESSAGING_SENDER_ID",
      appId: "APP_ID"
    };
    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);
  </script>

Follow Installation Instructions for Mobile: https://pub.dev/packages/firebase_auth

    classpath 'com.google.gms:google-services:4.2.0'

Actions

_auth.dispatch(CheckUser());
_userChanged = _fbAuth.onAuthChanged().listen((user) {
    _auth.dispatch(UpdateUser(user));
});
_auth.dispatch(LogoutEvent(_user));
_auth.dispatch(LoginEvent(_email, _password));
_auth.dispatch(LoginGuest());
_auth.dispatch(CreateAccount(_email, _password, displayName: _name));
_auth.dispatch(EditInfo(displayName: _name));
_auth.dispatch(ForgotPassword(_email));
_auth.dispatch(SendEmailVerification());