-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve social authentication (#5349)
- Loading branch information
1 parent
980c019
commit a3b4f97
Showing
13 changed files
with
269 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
cvat-ui/src/components/login-with-social-app/login-with-social-app.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (C) 2022 CVAT.ai Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React, { useEffect } from 'react'; | ||
import { useLocation, useHistory } from 'react-router'; | ||
import notification from 'antd/lib/notification'; | ||
import Spin from 'antd/lib/spin'; | ||
|
||
import { getCore } from 'cvat-core-wrapper'; | ||
|
||
const cvat = getCore(); | ||
|
||
export default function LoginWithSocialAppComponent(): JSX.Element { | ||
const location = useLocation(); | ||
const history = useHistory(); | ||
const search = new URLSearchParams(location.search); | ||
|
||
useEffect(() => { | ||
const provider = search.get('provider'); | ||
const code = search.get('code'); | ||
const process = search.get('process'); | ||
const scope = search.get('scope'); | ||
const authParams = search.get('auth_params'); | ||
|
||
if (provider && code) { | ||
cvat.server.loginWithSocialAccount(provider, code, authParams, process, scope) | ||
.then(() => window.location.reload()) | ||
.catch((exception: Error) => { | ||
if (exception.message.includes('Unverified email')) { | ||
history.push('/auth/email-verification-sent'); | ||
} | ||
history.push('/auth/login'); | ||
notification.error({ | ||
message: 'Could not log in with social account', | ||
description: 'Go to developer console', | ||
}); | ||
return Promise.reject(exception); | ||
}); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div className='cvat-login-page cvat-spinner-container'> | ||
<Spin size='large' className='cvat-spinner' /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.