mirror of
https://github.com/rjNemo/MERN_sample_app
synced 2026-06-09 01:56:41 +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 [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>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue