mirror of
https://github.com/rjNemo/MERN_sample_app
synced 2026-06-12 11:36:39 +00:00
enables SignUp with google
This commit is contained in:
parent
52f03d6027
commit
31e8f43973
2 changed files with 19 additions and 2 deletions
|
|
@ -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 SignUpFormBase = (props) => {
|
||||||
const [userName, setUserName] = useState("");
|
const [userName, setUserName] = useState("");
|
||||||
|
|
@ -62,6 +62,17 @@ const SignUpFormBase = (props) => {
|
||||||
.catch((err) => setError(err));
|
.catch((err) => setError(err));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClick = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
auth
|
||||||
|
.signInWithGoogle()
|
||||||
|
.then(() => {
|
||||||
|
cleanFields();
|
||||||
|
props.history.push(ROUTES.APP);
|
||||||
|
})
|
||||||
|
.catch((err) => setError(err));
|
||||||
|
};
|
||||||
|
|
||||||
const isInvalid =
|
const isInvalid =
|
||||||
password1 !== password2 ||
|
password1 !== password2 ||
|
||||||
password1 === "" ||
|
password1 === "" ||
|
||||||
|
|
@ -101,6 +112,9 @@ const SignUpFormBase = (props) => {
|
||||||
>
|
>
|
||||||
Sign Up
|
Sign Up
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button color="light" style={styles.button} block onClick={handleClick}>
|
||||||
|
Sign Up with Google
|
||||||
|
</Button>
|
||||||
{error && <p>{error.message}</p>}
|
{error && <p>{error.message}</p>}
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,10 @@ export default class Firebase {
|
||||||
|
|
||||||
provider = new app.auth.GoogleAuthProvider();
|
provider = new app.auth.GoogleAuthProvider();
|
||||||
|
|
||||||
signInWithGoogle = () => this.auth.signInWithPopup(this.provider);
|
signInWithGoogle = () =>
|
||||||
|
this.auth
|
||||||
|
// signInWithRedirect(this.provider);
|
||||||
|
.signInWithPopup(this.provider);
|
||||||
|
|
||||||
createUserWithEmailAndPassword = (email, password) =>
|
createUserWithEmailAndPassword = (email, password) =>
|
||||||
this.auth.createUserWithEmailAndPassword(email, password);
|
this.auth.createUserWithEmailAndPassword(email, password);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue