Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/strapi-admin/ee/admin/containers/AuthResponse/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import React, { useEffect, useRef, useCallback } from 'react';
import { useHistory, useRouteMatch } from 'react-router-dom';
import { useIntl } from 'react-intl';
import Cookies from 'js-cookie';
import { auth, LoadingIndicatorPage, request } from 'strapi-helper-plugin';
import { getRequestUrl } from '../../../../admin/src/utils';
const AuthResponse = () => {
const {
params: { authResponse },
} = useRouteMatch('/auth/login/:authResponse');
const { formatMessage } = useIntl();
const { push } = useHistory();
const formatMessageRef = useRef(formatMessage);
let redirectToOops = useCallback(() => {
push(
`/auth/oops?info=${encodeURIComponent(
formatMessageRef.current({
id: 'Auth.form.button.login.providers.error',
defaultMessage: 'We cannot connect you through the selected provider.',
})
)}`
);
}, [push]);
const fetchUserInfo = useCallback(async () => {
try {
const jwtToken = Cookies.get('jwtToken');
auth.clearAppStorage();
if (jwtToken) {
auth.setToken(jwtToken, true);
const requestUrl = getRequestUrl('users/me');
const { data } = await request(requestUrl, { method: 'GET' });
auth.setUserInfo(data, true);
Cookies.remove('jwtToken');
push('/auth/login');
}
} catch (e) {
redirectToOops();
}
}, [push, redirectToOops]);
useEffect(() => {
if (authResponse === 'error') {
redirectToOops();
}
if (authResponse === 'success') {
fetchUserInfo();
}
}, [authResponse, fetchUserInfo, redirectToOops]);
return <LoadingIndicatorPage />;
};
export default AuthResponse;
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0293 ]-- |