Skip to content

Commit 89897b1

Browse files
committed
add google auth
1 parent 65eff12 commit 89897b1

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
API_URL=https://forautobackend.herokuapp.com
2-
API_URL_A=http://localhost:3030
1+
API_URL_B=https://forautobackend.herokuapp.com
2+
API_URL=http://localhost:3030

components/AuthForm/parts/SignInForm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ const Component = ({ handleSubmit, onSubmit, children, title }) => {
2323
<form className={styles.container}>
2424
{title && <h4>{title}</h4>}
2525
<div className={styles.social}>
26-
<GoogleButton title="Sign in with Google" href="google" />
26+
<GoogleButton title="Sign in with Google" href="https://forautobackend.herokuapp.com/oauth/google" />
2727
</div>
2828
<div className={styles.social}>
29-
<FacebookButton title="Sign in with Facebook" href="facebook" />
29+
<FacebookButton title="Sign in with Facebook" href="https://forautobackend.herokuapp.com/oauth/facebook" />
3030
</div>
3131
{children}
3232
<BaseButton

pages/auth/index.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { useDispatch } from 'react-redux'
2+
import { useRouter } from 'next/router'
3+
import AuthCreators from '../../store/auth/creators'
4+
5+
const Auth = () => {
6+
const { push, asPath } = useRouter()
7+
const dispatch = useDispatch()
8+
if (asPath && asPath.includes('access_token')) {
9+
const accessToken = asPath.split('access_token=')[1];
10+
// @ts-ignore
11+
window.localStorage.setItem('feathers-jwt', accessToken);
12+
dispatch(AuthCreators.logIn({ strategy: 'jwt', accessToken }));
13+
} else {
14+
push('/');
15+
}
16+
return null;
17+
18+
}
19+
20+
export default Auth;

0 commit comments

Comments
 (0)