enables SignUp with google

This commit is contained in:
Ruidy Nemausat 2020-04-23 23:03:25 +02:00
parent 52f03d6027
commit 31e8f43973
2 changed files with 19 additions and 2 deletions

View file

@ -32,7 +32,7 @@ export default function SignUpPage() {
}
/**
* Holds the form state and validates the form.
* Holds the form state and validates the form. TODO: use an alert to display errors.
*/
const SignUpFormBase = (props) => {
const [userName, setUserName] = useState("");
@ -62,6 +62,17 @@ const SignUpFormBase = (props) => {
.catch((err) => setError(err));
};
const handleClick = (e) => {
e.preventDefault();
auth
.signInWithGoogle()
.then(() => {
cleanFields();
props.history.push(ROUTES.APP);
})
.catch((err) => setError(err));
};
const isInvalid =
password1 !== password2 ||
password1 === "" ||
@ -101,6 +112,9 @@ const SignUpFormBase = (props) => {
>
Sign Up
</Button>
<Button color="light" style={styles.button} block onClick={handleClick}>
Sign Up with Google
</Button>
{error && <p>{error.message}</p>}
</FormGroup>
</Form>

View file

@ -24,7 +24,10 @@ export default class Firebase {
provider = new app.auth.GoogleAuthProvider();
signInWithGoogle = () => this.auth.signInWithPopup(this.provider);
signInWithGoogle = () =>
this.auth
// signInWithRedirect(this.provider);
.signInWithPopup(this.provider);
createUserWithEmailAndPassword = (email, password) =>
this.auth.createUserWithEmailAndPassword(email, password);