Commit 43415c9f authored by ajlarrosa's avatar ajlarrosa

Avances

parent 5c116707
......@@ -26,4 +26,4 @@ jwt:
jwt_secret: secret.console.hpc.gensh.me
token_lifetime: 7200
issuer: issuer.ssh.gensh.me
query_token_key: _t
\ No newline at end of file
query_token_key: _t
No preview for this file type
This diff is collapsed.
This diff is collapsed.
......@@ -10,13 +10,20 @@ import apiRouters from '../config/api_routers';
const Signin = (props: RouteComponentProps) => {
React.useEffect(() => {
window.addEventListener('message', (event) => {
const baseUrl = process.env.REACT_APP_CLUSTER_URL as string;
console.log(event.origin);
console.log(process.env.REACT_APP_CLUSTER_URL);
console.log('-----');
console.log(!event.origin.includes(baseUrl));
console.log('-----');
console.log(event.data);
console.log('-----');
if (!event.origin.includes(process.env.REACT_APP_CLUSTER_URL!)) return;
doSignin(event.data);
});
}, []);
const { t } = useTranslation(['signin']);
const doSignin = (data: Record<string, string>) => {
Utils.axiosInstance
.post(Utils.loadUrl(apiRouters.router.sign_in, null), {
......@@ -26,22 +33,47 @@ const Signin = (props: RouteComponentProps) => {
passwd: data.password,
})
.then((response) => {
console.log(response);
try {
if (!response.data || response.data.has_error) {
switch (response.data.message) {
case 0:
console.log(t('signin:form_has_error'));
toaster.danger(t('signin:form_has_error'));
break;
case 1:
console.log(t('signin:form_error_passport'));
toaster.danger(t('signin:form_error_passport'));
break;
case 2:
console.log(t('signin:form_error_ssh_login'));
toaster.danger(t('signin:form_error_ssh_login'));
break;
}
if (window && window.parent) {
console.log('Send Message has error');
window.parent.postMessage(
{
message: 'close',
},
'*',
);
}
props.history.push('/');
} else {
if (!response.data.addition) {
toaster.danger(t('signin:form_error_remote_server'));
if (window && window.parent) {
console.log('Send Message Else');
window.parent.postMessage(
{
message: 'close',
},
'*',
);
}
props.history.push('/');
} else {
toaster.success(t('signin:signin_success'));
localStorage.setItem('user.host', data.host);
......@@ -55,11 +87,33 @@ const Signin = (props: RouteComponentProps) => {
}
}
} catch (e) {
console.log(e.message);
toaster.danger(t('signin:form_error_ssh_login'));
if (window && window.parent) {
console.log('Send Message Error 1');
window.parent.postMessage(
{
message: 'close',
},
'*',
);
}
props.history.push('/');
}
})
.catch((e: Error) => {
console.log(e.message);
toaster.danger(t('signin:form_error_ssh_login') + ': ' + e.message);
if (window && window.parent) {
console.log('Send Message Error 2');
window.parent.postMessage(
{
message: 'close',
},
'*',
);
}
props.history.push('/');
});
};
......@@ -74,7 +128,7 @@ const Signin = (props: RouteComponentProps) => {
<Heading marginBottom="0.6rem" marginTop="0.6rem" size={700}>
{t('signin:form_title')}
</Heading>
<span>Waiting for loging</span>
<span>Waiting for loging - Test 8</span>!
</div>
</Pane>
);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment