Commit 43415c9f authored by ajlarrosa's avatar ajlarrosa

Avances

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