Skip to content

Commit

Permalink
Install react-firebaseUI package
Browse files Browse the repository at this point in the history
  • Loading branch information
KristaRutz committed May 18, 2020
1 parent 6658913 commit 9d0de7c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"react": "^16.13.1",
"react-bootstrap": "^1.0.1",
"react-dom": "^16.13.1",
"react-firebaseui": "^4.1.0",
"react-icons": "^3.10.0",
"react-redux": "^7.1.3",
"react-redux-firebase": "^3.1.1",
Expand Down
59 changes: 51 additions & 8 deletions src/components/LogInForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,58 @@ import Form from "react-bootstrap/Form";
import Button from "react-bootstrap/Button";
import firebase from "firebase/app";
import * as firebaseui from "firebaseui";
import LoadingScreen from "./LoadingScreen";
import { StyledFirebaseAuth } from "react-firebaseui";

var ui = new firebaseui.auth.AuthUI(firebase.auth());

ui.start("#firebaseui-auth-container", {
signInOptions: [
{
provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
requireDisplayName: false,
const uiConfig = {
callbacks: {
signInSuccessWithAuthResult: function (authResult, redirectUrl) {
// User successfully signed in.
// Return type determines whether we continue the redirect automatically
// or whether we leave that to developer to handle.
return true;
},
uiShown: function () {
// The widget is rendered.
// Hide the loader.
document.getElementById("loader").style.display = "none";
},
},
// Will use popup for IDP Providers sign-in flow instead of the default, redirect.
signInFlow: "popup",
signInSuccessUrl: "<url-to-redirect-to-on-success>",
signInOptions: [
// Leave the lines as is for the providers you want to offer your users.
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
firebase.auth.FacebookAuthProvider.PROVIDER_ID,
firebase.auth.EmailAuthProvider.PROVIDER_ID,
],
});
// signInOptions: [
// {
// provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
// requireDisplayName: false,
// },
// {
// provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
// scopes: ["https://www.googleapis.com/auth/contacts.readonly"],
// customParameters: {
// prompt: "select_account",
// },
// },
// {
// provider: firebase.auth.FacebookAuthProvider.PROVIDER_ID,
// scopes: ["public_profile", "email", "user_friends"],
// },
// ],
// Terms of service url.
tosUrl: "<your-tos-url>",
// Privacy policy url.
privacyPolicyUrl: "<your-privacy-policy-url>",
};

const ui = new firebaseui.auth.AuthUI(firebase.auth());

ui.start("#firebaseui-auth-container", uiConfig);

if (ui.isPendingRedirect()) {
ui.start("#firebaseui-auth-container", uiConfig);
Expand All @@ -28,6 +68,9 @@ function LogInForm(props) {
<Button onClick={props.onRegisterClick}>Toggle register</Button>
<h1 className="display-2">Sign in to your account</h1>
<div id="firebaseui-auth-container"></div>
<div id="loader">
<LoadingScreen />
</div>
</Container>
);
}
Expand Down

0 comments on commit 9d0de7c

Please sign in to comment.