fix: github auth login (#250)
* fix: added PROJECT_ISSUES_LIST on the imports (#221) * fix: github signin by parsing email * refactor: changed variable names --------- Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com> Co-authored-by: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Co-authored-by: Vamsi Kurama <vamsi.kurama@gmail.com>
This commit is contained in:
parent
4ffa31fd02
commit
56030b1c2c
3 changed files with 36 additions and 27 deletions
|
|
@ -34,7 +34,7 @@ export const GithubLoginButton: FC<GithubLoginButtonProps> = (props) => {
|
|||
|
||||
return (
|
||||
<Link
|
||||
href={`https://github.com/login/oauth/authorize?client_id=${NEXT_PUBLIC_GITHUB_ID}&redirect_uri=${loginCallBackURL}`}
|
||||
href={`https://github.com/login/oauth/authorize?client_id=${NEXT_PUBLIC_GITHUB_ID}&redirect_uri=${loginCallBackURL}&scope=read:user,user:email`}
|
||||
>
|
||||
<button className="flex w-full items-center rounded bg-black px-3 py-2 text-sm text-white opacity-90 duration-300 hover:opacity-100">
|
||||
<Image
|
||||
|
|
|
|||
|
|
@ -62,27 +62,30 @@ const SignInPage: NextPage = () => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleGithubSignIn = (githubToken: string) => {
|
||||
setLoading(true);
|
||||
authenticationService
|
||||
.socialAuth({
|
||||
medium: "github",
|
||||
credential: githubToken,
|
||||
clientId: NEXT_PUBLIC_GITHUB_ID,
|
||||
})
|
||||
.then(async () => {
|
||||
await onSignInSuccess();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
setToastAlert({
|
||||
title: "Error signing in!",
|
||||
type: "error",
|
||||
message: "Something went wrong. Please try again later or contact the support team.",
|
||||
const handleGithubSignIn = useCallback(
|
||||
(credential: string) => {
|
||||
setLoading(true);
|
||||
authenticationService
|
||||
.socialAuth({
|
||||
medium: "github",
|
||||
credential,
|
||||
clientId: NEXT_PUBLIC_GITHUB_ID,
|
||||
})
|
||||
.then(async () => {
|
||||
await onSignInSuccess();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
setToastAlert({
|
||||
title: "Error signing in!",
|
||||
type: "error",
|
||||
message: "Something went wrong. Please try again later or contact the support team.",
|
||||
});
|
||||
setLoading(false);
|
||||
});
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
},
|
||||
[onSignInSuccess, setToastAlert]
|
||||
);
|
||||
|
||||
return (
|
||||
<DefaultLayout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue