Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
added very secure google token (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
tr0ub1eM4k3r authored Mar 4, 2022
1 parent 987a5b1 commit 059df35
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
32 changes: 16 additions & 16 deletions src/components/univeralComponents/LoginButtonGoogle.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useContext } from 'react'
import GoogleLogin from 'react-google-login'
import React, { useContext } from "react";
import GoogleLogin from "react-google-login";
import { useNavigate } from "react-router-dom";
import { Context } from '../../Context';

import { Context } from "../../Context";
import configData from "../../config.json";

export default function LoginButtonGoogle() {
const navigate = useNavigate();
Expand All @@ -12,21 +12,21 @@ export default function LoginButtonGoogle() {
setIsLoggedIn(true);
navigate("/panel");
console.log("Successfully logged in!");
}
};

const responseGoogleFailed = (response) => {
console.log("Failed logging in!");
console.log(response);
}
};

return (
<GoogleLogin
clientId="258375953305-7j1t10b7nlkrlgclfm94a86q55k3v5d9.apps.googleusercontent.com"
buttonText="Login with Google"
onSuccess={responseGoogle}
onFailure={responseGoogleFailed}
cookiePolicy={'single_host_origin'}
isSignedIn={true}
/>
)
}
<GoogleLogin
clientId={configData.GOOGLE_TOKEN}
buttonText="Login with Google"
onSuccess={responseGoogle}
onFailure={responseGoogleFailed}
cookiePolicy={"single_host_origin"}
isSignedIn={true}
/>
);
}
21 changes: 10 additions & 11 deletions src/components/univeralComponents/LogoutButtonGoogle.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { Fragment, useContext } from 'react'
import { GoogleLogout } from 'react-google-login'
import React, { useContext } from "react";
import { GoogleLogout } from "react-google-login";
import { useNavigate } from "react-router-dom";
import { LogoutButton } from '../../Styles/Styled';
import { Context } from '../../Context';
import { LogoutButton } from "../../Styles/Styled";
import { Context } from "../../Context";
import configData from "../../config.json";

export default function LogoutButtonGoogle() {
const navigate = useNavigate();
Expand All @@ -12,17 +13,15 @@ export default function LogoutButtonGoogle() {
setIsLoggedIn(false);
navigate("/");
console.log("Successfully logged out!");
}
};

return (
<LogoutButton>
<GoogleLogout
clientId="258375953305-7j1t10b7nlkrlgclfm94a86q55k3v5d9.apps.googleusercontent.com"
clientId={configData.GOOGLE_TOKEN}
buttonText="Logout"

onLogoutSuccess = {logout}>
</GoogleLogout>
onLogoutSuccess={logout}
></GoogleLogout>
</LogoutButton>
)
);
}

3 changes: 3 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"GOOGLE_TOKEN": "258375953305-7j1t10b7nlkrlgclfm94a86q55k3v5d9.apps.googleusercontent.com"
}

0 comments on commit 059df35

Please sign in to comment.