Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!hash_on) {
return undefined;
}
if (hash_on !== 'consumer' && !key) {
return undefined;
}
}
if (pass_host === 'rewrite' && !upstream_host) {
return undefined;
}
if (checks?.passive && !checks.active) {
notification.error({
message: formatMessage({id: 'component.upstream.other.health-check.invalid'}),
description: formatMessage({id: 'component.upstream.other.health-check.passive-only'})
})
return undefined
}
/**
* nodes will be [] or node list
* when upstream_id === none, None === undefined
*/
if (nodes) {
// NOTE: https://github.com/ant-design/ant-design/issues/27396
data.nodes = nodes?.map((item) => {
return pick(item, ['host', 'port', 'weight']);
});
return data;
}
submit: async ({ username, password }) => {
if (username !== '' && password !== '') {
try {
const result = await request('/user/login', {
method: 'POST',
requestType: 'json',
data: {
username,
password,
},
});
localStorage.setItem('token', result.data.token);
return {
status: true,
message: formatMessage({ id: 'component.user.loginMethodPassword.success' }),
data: [],
};
} catch (e) {
// NOTE: API failed, using errorHandler
return {
status: false,
message: '',
data: [],
};
}
} else {
return {
status: false,
message: formatMessage({ id: 'component.user.loginMethodPassword.fieldInvalid' }),
data: [],
};
return undefined;
}
if (hash_on !== 'consumer' && !key) {
return undefined;
}
}
if (pass_host === 'rewrite' && !upstream_host) {
return undefined;
}
if (checks?.passive && !checks.active) {
notification.error({
message: formatMessage({id: 'component.upstream.other.health-check.invalid'}),
description: formatMessage({id: 'component.upstream.other.health-check.passive-only'})
})
return undefined
}
/**
* nodes will be [] or node list
* when upstream_id === none, None === undefined
*/
if (nodes) {
// NOTE: https://github.com/ant-design/ant-design/issues/27396
data.nodes = nodes?.map((item) => {
return pick(item, ['host', 'port', 'weight']);
});
return data;
}
return true;
};
const key = `open${Date.now()}`;
const btn = (
<button type="primary"> {
notification.close(key);
reloadSW();
}}
>
{formatMessage({ id: 'app.pwa.serviceworker.updated.ok' })}
</button>
);
notification.open({
message: formatMessage({ id: 'app.pwa.serviceworker.updated' }),
description: formatMessage({ id: 'app.pwa.serviceworker.updated.hint' }),
btn,
key,
onClose: async () => {},
});
});
} else if ('serviceWorker' in navigator) {
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { Form, Input, Tooltip } from 'antd';
import type { FormInstance } from 'antd/lib/form';
import { UserOutlined, LockTwoTone } from '@ant-design/icons';
import { request, formatMessage } from 'umi';
import type { UserModule } from '@/pages/User/typing';
const formRef = React.createRef();
const LoginMethodPassword: UserModule.LoginMethod = {
id: 'password',
name: formatMessage({ id: 'component.user.loginMethodPassword' }),
render: () => {
return (
<form name="control-ref">
</form>
findParent({ node }) {
const bbox = node.getBBox()
return this.getNodes().filter((item) => {
const data = item.getData()
if (data && data.parent) {
const targetBBox = item.getBBox()
return bbox.isIntersectWithRect(targetBBox)
}
return false
})
},
},
}
export const DEFAULT_STENCIL_OPINIONS: Partial = {
title: formatMessage({ id: 'component.plugin-flow.text.nodes-area' }),
stencilGraphWidth: DEFAULT_STENCIL_WIDTH,
search: (cell, keyword) => {
if (keyword) {
return (cell as any).label?.indexOf(keyword) !== -1
}
return true
},
notFoundText: formatMessage({ id: 'component.plugin-flow.text.nodes.not-found' }),
placeholder: formatMessage({ id: 'component.plugin-flow.text.search-nodes.placeholder' }),
collapsable: true,
}
export const DEFAULT_SHAPE_RECT_OPINIONS = {
inherit: 'rect',
width: 80,
height: 42,
})
},
},
}
export const DEFAULT_STENCIL_OPINIONS: Partial = {
title: formatMessage({ id: 'component.plugin-flow.text.nodes-area' }),
stencilGraphWidth: DEFAULT_STENCIL_WIDTH,
search: (cell, keyword) => {
if (keyword) {
return (cell as any).label?.indexOf(keyword) !== -1
}
return true
},
notFoundText: formatMessage({ id: 'component.plugin-flow.text.nodes.not-found' }),
placeholder: formatMessage({ id: 'component.plugin-flow.text.search-nodes.placeholder' }),
collapsable: true,
}
export const DEFAULT_SHAPE_RECT_OPINIONS = {
inherit: 'rect',
width: 80,
height: 42,
attrs: {
body: {
stroke: '#5F95FF',
strokeWidth: 1,
fill: 'rgba(95,149,255,0.05)',
},
fo: {
refWidth: '100%',
refHeight: '100%',
};
const key = `open${Date.now()}`;
const btn = (
<button type="primary"> {
notification.close(key);
reloadSW();
}}
>
{formatMessage({ id: 'app.pwa.serviceworker.updated.ok' })}
</button>
);
notification.open({
message: formatMessage({ id: 'app.pwa.serviceworker.updated' }),
description: formatMessage({ id: 'app.pwa.serviceworker.updated.hint' }),
btn,
key,
onClose: async () => {},
});
});
} else if ('serviceWorker' in navigator) {
return false
})
},
},
}
export const DEFAULT_STENCIL_OPINIONS: Partial = {
title: formatMessage({ id: 'component.plugin-flow.text.nodes-area' }),
stencilGraphWidth: DEFAULT_STENCIL_WIDTH,
search: (cell, keyword) => {
if (keyword) {
return (cell as any).label?.indexOf(keyword) !== -1
}
return true
},
notFoundText: formatMessage({ id: 'component.plugin-flow.text.nodes.not-found' }),
placeholder: formatMessage({ id: 'component.plugin-flow.text.search-nodes.placeholder' }),
collapsable: true,
}
export const DEFAULT_SHAPE_RECT_OPINIONS = {
inherit: 'rect',
width: 80,
height: 42,
attrs: {
body: {
stroke: '#5F95FF',
strokeWidth: 1,
fill: 'rgba(95,149,255,0.05)',
},
fo: {
refWidth: '100%',
window.addEventListener('sw.offline', () => {
message.warning(formatMessage({ id: 'app.pwa.offline' }));
});