Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

```
NEXT_PUBLIC_DEV_SERVER_URL=http://localhost:3000/graphql
NEXT_PUBLIC_THIRD_PARTY_API_URL=http://localhost:3000/auth
```

## Environment Variables
Expand Down
28 changes: 25 additions & 3 deletions src/app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useState } from 'react';
import { useState, useEffect } from 'react';
import FacebookIcon from 'mdi-react/FacebookIcon';
import GooglePlusIcon from 'mdi-react/GooglePlusIcon';
import {
Expand Down Expand Up @@ -59,6 +59,28 @@ const Login = () => {
}
};

useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get('token');
if (token) {
if (typeof window !== 'undefined') {
localStorage.setItem(EMAIL, '');
localStorage.setItem(AUTH_TOKEN, '');
sessionStorage.setItem(AUTH_TOKEN, token ?? '');
}
if (originUrl && originUrl !== '/') {
router.back();
} else {
router.push('dashboard');
}
}
}, [router, originUrl]);

const handleThirdPartyLogin = (provider: string) => {
const thirdPartyApiUrl = process.env.NEXT_PUBLIC_THIRD_PARTY_API_URL;
window.location.href = `${thirdPartyApiUrl}/${provider}`;
};

return (
<AccountWrap>
<AccountContent>
Expand All @@ -82,11 +104,11 @@ const Login = () => {
{/* @ts-ignore - Ignoring because of complex union types incorrectly inferred */}
<AccountSocialButtonFacebook
className="account__social-btn account__social-btn--facebook"
to="/login"
onClick={() => handleThirdPartyLogin('facebook')}
>
<FacebookIcon />
</AccountSocialButtonFacebook>
<AccountSocialButtonGoogle to="/login">
<AccountSocialButtonGoogle onClick={() => handleThirdPartyLogin('google')}>
<GooglePlusIcon />
</AccountSocialButtonGoogle>
</AccountSocial>
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/codegen/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export type Mutation = {
/** Create exchange key */
createExchangeKey: Scalars['Boolean']['output'];
/** Create new user */
createUser: Scalars['Boolean']['output'];
createUser: Scalars['String']['output'];
/** Hard delete an user */
deleteUser: Scalars['Boolean']['output'];
/** Hard delete an user key */
Expand Down