chore(style): allow case declarations and ban var (#987)

* chore(style): allow case declarations

* chore(style): ban `var` and prefer `const`
This commit is contained in:
q1anx1
2022-08-08 23:35:24 +08:00
committed by GitHub
parent 802995ed16
commit deed857788
65 changed files with 187 additions and 182 deletions

View File

@ -42,7 +42,13 @@
"space-before-function-paren": ["error", "never"], "space-before-function-paren": ["error", "never"],
"no-trailing-spaces": ["error", { "ignoreComments": true }], "no-trailing-spaces": ["error", { "ignoreComments": true }],
"eol-last": ["error", "always"], "eol-last": ["error", "always"],
// "no-var": ["error"], "no-var": ["error"],
"prefer-const": [
"error",
{
"destructuring": "all"
}
],
"curly": ["error", "all"], "curly": ["error", "all"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }], "brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"no-mixed-spaces-and-tabs": "error", "no-mixed-spaces-and-tabs": "error",
@ -89,7 +95,7 @@
// don't use strict mod now, otherwise there are a lot of errors in the codebase // don't use strict mod now, otherwise there are a lot of errors in the codebase
"no-unused-vars": "off", "no-unused-vars": "off",
"react/no-deprecated": "warn", "react/no-deprecated": "warn",
"no-case-declarations": "warn", "no-case-declarations": "off",
"react/jsx-key": "warn" "react/jsx-key": "warn"
} }
} }

View File

@ -38,7 +38,7 @@ class AccountTable extends React.Component {
} }
addRow(table) { addRow(table) {
let row = {name: Setting.getNewRowNameForTable(table, "Please select an account item"), visible: true, viewRule: "Public", modifyRule: "Self"}; const row = {name: Setting.getNewRowNameForTable(table, "Please select an account item"), visible: true, viewRule: "Public", modifyRule: "Self"};
if (table === undefined) { if (table === undefined) {
table = []; table = [];
} }
@ -141,7 +141,7 @@ class AccountTable extends React.Component {
return null; return null;
} }
let options = [ const options = [
{id: "Public", name: "Public"}, {id: "Public", name: "Public"},
{id: "Self", name: "Self"}, {id: "Self", name: "Self"},
{id: "Admin", name: "Admin"}, {id: "Admin", name: "Admin"},

View File

@ -182,7 +182,7 @@ class App extends Component {
} }
setLanguage(account) { setLanguage(account) {
let language = account?.language; const language = account?.language;
if (language !== "" && language !== i18next.language) { if (language !== "" && language !== i18next.language) {
Setting.setLanguage(language); Setting.setLanguage(language);
} }
@ -242,7 +242,7 @@ class App extends Component {
}); });
Setting.showMessage("success", "Logged out successfully"); Setting.showMessage("success", "Logged out successfully");
let redirectUri = res.data2; const redirectUri = res.data2;
if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") { if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") {
Setting.goToLink(redirectUri); Setting.goToLink(redirectUri);
} else if (owner !== "built-in") { } else if (owner !== "built-in") {
@ -322,7 +322,7 @@ class App extends Component {
} }
renderAccount() { renderAccount() {
let res = []; const res = [];
if (this.state.account === undefined) { if (this.state.account === undefined) {
return null; return null;
@ -349,7 +349,7 @@ class App extends Component {
} }
renderMenu() { renderMenu() {
let res = []; const res = [];
if (this.state.account === null || this.state.account === undefined) { if (this.state.account === null || this.state.account === undefined) {
return []; return [];

View File

@ -120,7 +120,7 @@ class ApplicationEditPage extends React.Component {
updateApplicationField(key, value) { updateApplicationField(key, value) {
value = this.parseApplicationField(key, value); value = this.parseApplicationField(key, value);
let application = this.state.application; const application = this.state.application;
application[key] = value; application[key] = value;
this.setState({ this.setState({
application: application, application: application,
@ -566,8 +566,8 @@ class ApplicationEditPage extends React.Component {
renderSignupSigninPreview() { renderSignupSigninPreview() {
let signUpUrl = `/signup/${this.state.application.name}`; let signUpUrl = `/signup/${this.state.application.name}`;
let signInUrl = `/login/oauth/authorize?client_id=${this.state.application.clientId}&response_type=code&redirect_uri=${this.state.application.redirectUris[0]}&scope=read&state=casdoor`; const signInUrl = `/login/oauth/authorize?client_id=${this.state.application.clientId}&response_type=code&redirect_uri=${this.state.application.redirectUris[0]}&scope=read&state=casdoor`;
let maskStyle = {position: "absolute", top: "0px", left: "0px", zIndex: 10, height: "100%", width: "100%", background: "rgba(0,0,0,0.4)"}; const maskStyle = {position: "absolute", top: "0px", left: "0px", zIndex: 10, height: "100%", width: "100%", background: "rgba(0,0,0,0.4)"};
if (!this.state.application.enablePassword) { if (!this.state.application.enablePassword) {
signUpUrl = signInUrl.replace("/login/oauth/authorize", "/signup/oauth/authorize"); signUpUrl = signInUrl.replace("/login/oauth/authorize", "/signup/oauth/authorize");
} }
@ -613,8 +613,8 @@ class ApplicationEditPage extends React.Component {
} }
renderPromptPreview() { renderPromptPreview() {
let promptUrl = `/prompt/${this.state.application.name}`; const promptUrl = `/prompt/${this.state.application.name}`;
let maskStyle = {position: "absolute", top: "0px", left: "0px", zIndex: 10, height: "100%", width: "100%", background: "rgba(0,0,0,0.4)"}; const maskStyle = {position: "absolute", top: "0px", left: "0px", zIndex: 10, height: "100%", width: "100%", background: "rgba(0,0,0,0.4)"};
return ( return (
<Col span={11}> <Col span={11}>
<Button style={{marginBottom: "10px"}} type="primary" shape="round" icon={<CopyOutlined />} onClick={() => { <Button style={{marginBottom: "10px"}} type="primary" shape="round" icon={<CopyOutlined />} onClick={() => {
@ -634,7 +634,7 @@ class ApplicationEditPage extends React.Component {
} }
submitApplicationEdit(willExist) { submitApplicationEdit(willExist) {
let application = Setting.deepCopy(this.state.application); const application = Setting.deepCopy(this.state.application);
ApplicationBackend.updateApplication(this.state.application.owner, this.state.applicationName, application) ApplicationBackend.updateApplication(this.state.application.owner, this.state.applicationName, application)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -250,8 +250,8 @@ class ApplicationListPage extends BaseListPage {
} }
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; const field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
this.setState({loading: true}); this.setState({loading: true});
ApplicationBackend.getApplications("admin", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) ApplicationBackend.getApplications("admin", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => { .then((res) => {

View File

@ -57,7 +57,7 @@ class CertEditPage extends React.Component {
updateCertField(key, value) { updateCertField(key, value) {
value = this.parseCertField(key, value); value = this.parseCertField(key, value);
let cert = this.state.cert; const cert = this.state.cert;
cert[key] = value; cert[key] = value;
this.setState({ this.setState({
cert: cert, cert: cert,
@ -214,7 +214,7 @@ class CertEditPage extends React.Component {
} }
submitCertEdit(willExist) { submitCertEdit(willExist) {
let cert = Setting.deepCopy(this.state.cert); const cert = Setting.deepCopy(this.state.cert);
CertBackend.updateCert(this.state.cert.owner, this.state.certName, cert) CertBackend.updateCert(this.state.cert.owner, this.state.certName, cert)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -198,7 +198,7 @@ class CertListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.category !== undefined && params.category !== null) { if (params.category !== undefined && params.category !== null) {
field = "category"; field = "category";
value = params.category; value = params.category;

View File

@ -35,7 +35,7 @@ class LdapSyncPage extends React.Component {
} }
syncUsers() { syncUsers() {
let selectedUsers = this.state.selectedUsers; const selectedUsers = this.state.selectedUsers;
if (selectedUsers === null || selectedUsers.length === 0) { if (selectedUsers === null || selectedUsers.length === 0) {
Setting.showMessage("error", "Please select al least 1 user first"); Setting.showMessage("error", "Please select al least 1 user first");
return; return;
@ -44,10 +44,10 @@ class LdapSyncPage extends React.Component {
LdapBackend.syncUsers(this.state.ldap.owner, this.state.ldap.id, selectedUsers) LdapBackend.syncUsers(this.state.ldap.owner, this.state.ldap.id, selectedUsers)
.then((res => { .then((res => {
if (res.status === "ok") { if (res.status === "ok") {
let exist = res.data.exist; const exist = res.data.exist;
let failed = res.data.failed; const failed = res.data.failed;
let existUser = []; const existUser = [];
let failedUser = []; const failedUser = [];
if ((!exist || exist.length === 0) && (!failed || failed.length === 0)) { if ((!exist || exist.length === 0) && (!failed || failed.length === 0)) {
Setting.goToLink(`/organizations/${this.state.ldap.owner}/users`); Setting.goToLink(`/organizations/${this.state.ldap.owner}/users`);
@ -103,7 +103,7 @@ class LdapSyncPage extends React.Component {
} }
getExistUsers(owner, users) { getExistUsers(owner, users) {
let uuidArray = []; const uuidArray = [];
users.forEach(elem => { users.forEach(elem => {
uuidArray.push(elem.uuid); uuidArray.push(elem.uuid);
}); });
@ -119,11 +119,11 @@ class LdapSyncPage extends React.Component {
} }
buildValArray(data, key) { buildValArray(data, key) {
let valTypesArray = []; const valTypesArray = [];
if (data !== null && data.length > 0) { if (data !== null && data.length > 0) {
data.forEach(elem => { data.forEach(elem => {
let val = elem[key]; const val = elem[key];
if (!valTypesArray.includes(val)) { if (!valTypesArray.includes(val)) {
valTypesArray.push(val); valTypesArray.push(val);
} }
@ -133,10 +133,10 @@ class LdapSyncPage extends React.Component {
} }
buildFilter(data, key) { buildFilter(data, key) {
let filterArray = []; const filterArray = [];
if (data !== null && data.length > 0) { if (data !== null && data.length > 0) {
let valArray = this.buildValArray(data, key); const valArray = this.buildValArray(data, key);
valArray.forEach(elem => { valArray.forEach(elem => {
filterArray.push({ filterArray.push({
text: elem, text: elem,

View File

@ -81,7 +81,7 @@ class ModelEditPage extends React.Component {
updateModelField(key, value) { updateModelField(key, value) {
value = this.parseModelField(key, value); value = this.parseModelField(key, value);
let model = this.state.model; const model = this.state.model;
model[key] = value; model[key] = value;
this.setState({ this.setState({
model: model, model: model,
@ -155,7 +155,7 @@ class ModelEditPage extends React.Component {
} }
submitModelEdit(willExist) { submitModelEdit(willExist) {
let model = Setting.deepCopy(this.state.model); const model = Setting.deepCopy(this.state.model);
ModelBackend.updateModel(this.state.organizationName, this.state.modelName, model) ModelBackend.updateModel(this.state.organizationName, this.state.modelName, model)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -174,7 +174,7 @@ class ModelListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.type !== undefined && params.type !== null) { if (params.type !== undefined && params.type !== null) {
field = "type"; field = "type";
value = params.type; value = params.type;

View File

@ -75,7 +75,7 @@ class OrganizationEditPage extends React.Component {
updateOrganizationField(key, value) { updateOrganizationField(key, value) {
value = this.parseOrganizationField(key, value); value = this.parseOrganizationField(key, value);
let organization = this.state.organization; const organization = this.state.organization;
organization[key] = value; organization[key] = value;
this.setState({ this.setState({
organization: organization, organization: organization,
@ -283,7 +283,7 @@ class OrganizationEditPage extends React.Component {
} }
submitOrganizationEdit(willExist) { submitOrganizationEdit(willExist) {
let organization = Setting.deepCopy(this.state.organization); const organization = Setting.deepCopy(this.state.organization);
OrganizationBackend.updateOrganization(this.state.organization.owner, this.state.organizationName, organization) OrganizationBackend.updateOrganization(this.state.organization.owner, this.state.organizationName, organization)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -266,7 +266,7 @@ class OrganizationListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.passwordType !== undefined && params.passwordType !== null) { if (params.passwordType !== undefined && params.passwordType !== null) {
field = "passwordType"; field = "passwordType";
value = params.passwordType; value = params.passwordType;

View File

@ -54,7 +54,7 @@ export const PasswordModal = (props) => {
}); });
}; };
let hasOldPassword = user.password !== ""; const hasOldPassword = user.password !== "";
return ( return (
<Row> <Row>

View File

@ -60,7 +60,7 @@ class PaymentEditPage extends React.Component {
updatePaymentField(key, value) { updatePaymentField(key, value) {
value = this.parsePaymentField(key, value); value = this.parsePaymentField(key, value);
let payment = this.state.payment; const payment = this.state.payment;
payment[key] = value; payment[key] = value;
this.setState({ this.setState({
payment: payment, payment: payment,
@ -440,7 +440,7 @@ class PaymentEditPage extends React.Component {
return; return;
} }
let payment = Setting.deepCopy(this.state.payment); const payment = Setting.deepCopy(this.state.payment);
PaymentBackend.updatePayment(this.state.payment.owner, this.state.paymentName, payment) PaymentBackend.updatePayment(this.state.payment.owner, this.state.paymentName, payment)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -250,7 +250,7 @@ class PaymentListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.type !== undefined && params.type !== null) { if (params.type !== undefined && params.type !== null) {
field = "type"; field = "type";
value = params.type; value = params.type;

View File

@ -116,7 +116,7 @@ class PermissionEditPage extends React.Component {
updatePermissionField(key, value) { updatePermissionField(key, value) {
value = this.parsePermissionField(key, value); value = this.parsePermissionField(key, value);
let permission = this.state.permission; const permission = this.state.permission;
permission[key] = value; permission[key] = value;
this.setState({ this.setState({
permission: permission, permission: permission,
@ -288,7 +288,7 @@ class PermissionEditPage extends React.Component {
} }
submitPermissionEdit(willExist) { submitPermissionEdit(willExist) {
let permission = Setting.deepCopy(this.state.permission); const permission = Setting.deepCopy(this.state.permission);
PermissionBackend.updatePermission(this.state.organizationName, this.state.permissionName, permission) PermissionBackend.updatePermission(this.state.organizationName, this.state.permissionName, permission)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -243,7 +243,7 @@ class PermissionListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.type !== undefined && params.type !== null) { if (params.type !== undefined && params.type !== null) {
field = "type"; field = "type";
value = params.type; value = params.type;

View File

@ -69,7 +69,7 @@ class ProductEditPage extends React.Component {
updateProductField(key, value) { updateProductField(key, value) {
value = this.parseProductField(key, value); value = this.parseProductField(key, value);
let product = this.state.product; const product = this.state.product;
product[key] = value; product[key] = value;
this.setState({ this.setState({
product: product, product: product,
@ -252,7 +252,7 @@ class ProductEditPage extends React.Component {
} }
renderPreview() { renderPreview() {
let buyUrl = `/products/${this.state.product.name}/buy`; const buyUrl = `/products/${this.state.product.name}/buy`;
return ( return (
<Col span={22} style={{display: "flex", flexDirection: "column"}}> <Col span={22} style={{display: "flex", flexDirection: "column"}}>
<a style={{marginBottom: "10px", display: "flex"}} target="_blank" rel="noreferrer" href={buyUrl}> <a style={{marginBottom: "10px", display: "flex"}} target="_blank" rel="noreferrer" href={buyUrl}>
@ -268,7 +268,7 @@ class ProductEditPage extends React.Component {
} }
submitProductEdit(willExist) { submitProductEdit(willExist) {
let product = Setting.deepCopy(this.state.product); const product = Setting.deepCopy(this.state.product);
ProductBackend.updateProduct(this.state.product.owner, this.state.productName, product) ProductBackend.updateProduct(this.state.product.owner, this.state.productName, product)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -269,7 +269,7 @@ class ProductListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.type !== undefined && params.type !== null) { if (params.type !== undefined && params.type !== null) {
field = "type"; field = "type";
value = params.type; value = params.type;

View File

@ -61,7 +61,7 @@ class ProviderEditPage extends React.Component {
updateProviderField(key, value) { updateProviderField(key, value) {
value = this.parseProviderField(key, value); value = this.parseProviderField(key, value);
let provider = this.state.provider; const provider = this.state.provider;
provider[key] = value; provider[key] = value;
this.setState({ this.setState({
provider: provider, provider: provider,
@ -148,11 +148,11 @@ class ProviderEditPage extends React.Component {
} }
loadSamlConfiguration() { loadSamlConfiguration() {
var parser = new DOMParser(); const parser = new DOMParser();
var xmlDoc = parser.parseFromString(this.state.provider.metadata, "text/xml"); const xmlDoc = parser.parseFromString(this.state.provider.metadata, "text/xml");
var cert = xmlDoc.getElementsByTagName("ds:X509Certificate")[0].childNodes[0].nodeValue; const cert = xmlDoc.getElementsByTagName("ds:X509Certificate")[0].childNodes[0].nodeValue;
var endpoint = xmlDoc.getElementsByTagName("md:SingleSignOnService")[0].getAttribute("Location"); const endpoint = xmlDoc.getElementsByTagName("md:SingleSignOnService")[0].getAttribute("Location");
var issuerUrl = xmlDoc.getElementsByTagName("md:EntityDescriptor")[0].getAttribute("entityID"); const issuerUrl = xmlDoc.getElementsByTagName("md:EntityDescriptor")[0].getAttribute("entityID");
this.updateProviderField("idP", cert); this.updateProviderField("idP", cert);
this.updateProviderField("endpoint", endpoint); this.updateProviderField("endpoint", endpoint);
this.updateProviderField("issuerUrl", issuerUrl); this.updateProviderField("issuerUrl", issuerUrl);
@ -717,7 +717,7 @@ class ProviderEditPage extends React.Component {
} }
submitProviderEdit(willExist) { submitProviderEdit(willExist) {
let provider = Setting.deepCopy(this.state.provider); const provider = Setting.deepCopy(this.state.provider);
ProviderBackend.updateProvider(this.state.provider.owner, this.state.providerName, provider) ProviderBackend.updateProvider(this.state.provider.owner, this.state.providerName, provider)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -215,7 +215,7 @@ class ProviderListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.category !== undefined && params.category !== null) { if (params.category !== undefined && params.category !== null) {
field = "category"; field = "category";
value = params.category; value = params.category;

View File

@ -39,7 +39,7 @@ class ProviderTable extends React.Component {
} }
addRow(table) { addRow(table) {
let row = {name: Setting.getNewRowNameForTable(table, "Please select a provider"), canSignUp: true, canSignIn: true, canUnlink: true, alertType: "None"}; const row = {name: Setting.getNewRowNameForTable(table, "Please select a provider"), canSignUp: true, canSignIn: true, canUnlink: true, alertType: "None"};
if (table === undefined) { if (table === undefined) {
table = []; table = [];
} }

View File

@ -199,7 +199,7 @@ class RecordListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.method !== undefined && params.method !== null) { if (params.method !== undefined && params.method !== null) {
field = "method"; field = "method";
value = params.method; value = params.method;

View File

@ -291,8 +291,8 @@ class ResourceListPage extends BaseListPage {
} }
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; const field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
this.setState({loading: true}); this.setState({loading: true});
ResourceBackend.getResources(this.props.account.owner, this.props.account.name, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) ResourceBackend.getResources(this.props.account.owner, this.props.account.name, params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => { .then((res) => {

View File

@ -91,7 +91,7 @@ class RoleEditPage extends React.Component {
updateRoleField(key, value) { updateRoleField(key, value) {
value = this.parseRoleField(key, value); value = this.parseRoleField(key, value);
let role = this.state.role; const role = this.state.role;
role[key] = value; role[key] = value;
this.setState({ this.setState({
role: role, role: role,
@ -179,7 +179,7 @@ class RoleEditPage extends React.Component {
} }
submitRoleEdit(willExist) { submitRoleEdit(willExist) {
let role = Setting.deepCopy(this.state.role); const role = Setting.deepCopy(this.state.role);
RoleBackend.updateRole(this.state.organizationName, this.state.roleName, role) RoleBackend.updateRole(this.state.organizationName, this.state.roleName, role)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -194,7 +194,7 @@ class RoleListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.type !== undefined && params.type !== null) { if (params.type !== undefined && params.type !== null) {
field = "type"; field = "type";
value = params.type; value = params.type;

View File

@ -23,7 +23,7 @@ import {authConfig} from "./auth/Auth";
import {Helmet} from "react-helmet"; import {Helmet} from "react-helmet";
import * as Conf from "./Conf"; import * as Conf from "./Conf";
export let ServerUrl = ""; export const ServerUrl = "";
// export const StaticBaseUrl = "https://cdn.jsdelivr.net/gh/casbin/static"; // export const StaticBaseUrl = "https://cdn.jsdelivr.net/gh/casbin/static";
export const StaticBaseUrl = "https://cdn.casbin.org"; export const StaticBaseUrl = "https://cdn.casbin.org";
@ -136,11 +136,11 @@ export function getCountryRegionData() {
language = Conf.DefaultLanguage; language = Conf.DefaultLanguage;
} }
var countries = require("i18n-iso-countries"); const countries = require("i18n-iso-countries");
countries.registerLocale(require("i18n-iso-countries/langs/" + language + ".json")); countries.registerLocale(require("i18n-iso-countries/langs/" + language + ".json"));
var data = countries.getNames(language, {select: "official"}); const data = countries.getNames(language, {select: "official"});
var result = []; const result = [];
for (var i in data) {result.push({code: i, name: data[i]});} for (const i in data) {result.push({code: i, name: data[i]});}
return result; return result;
} }
@ -335,7 +335,7 @@ export function openLink(link) {
export function openLinkSafe(link) { export function openLinkSafe(link) {
// Javascript window.open issue in safari // Javascript window.open issue in safari
// https://stackoverflow.com/questions/45569893/javascript-window-open-issue-in-safari // https://stackoverflow.com/questions/45569893/javascript-window-open-issue-in-safari
let a = document.createElement("a"); const a = document.createElement("a");
a.href = link; a.href = link;
a.setAttribute("target", "_blank"); a.setAttribute("target", "_blank");
a.click(); a.click();
@ -445,9 +445,9 @@ export function getFriendlyFileSize(size) {
return size + " B"; return size + " B";
} }
let i = Math.floor(Math.log(size) / Math.log(1024)); const i = Math.floor(Math.log(size) / Math.log(1024));
let num = (size / Math.pow(1024, i)); let num = (size / Math.pow(1024, i));
let round = Math.round(num); const round = Math.round(num);
num = round < 10 ? num.toFixed(2) : round < 100 ? num.toFixed(1) : round; num = round < 10 ? num.toFixed(2) : round < 100 ? num.toFixed(1) : round;
return `${num} ${"KMGTPEZY"[i - 1]}B`; return `${num} ${"KMGTPEZY"[i - 1]}B`;
} }
@ -456,7 +456,7 @@ function getRandomInt(s) {
let hash = 0; let hash = 0;
if (s.length !== 0) { if (s.length !== 0) {
for (let i = 0; i < s.length; i++) { for (let i = 0; i < s.length; i++) {
let char = s.charCodeAt(i); const char = s.charCodeAt(i);
hash = ((hash << 5) - hash) + char; hash = ((hash << 5) - hash) + char;
hash = hash & hash; hash = hash & hash;
} }
@ -772,7 +772,7 @@ export function getMaskedEmail(email) {
username = maskString(username); username = maskString(username);
const domain = tokens[1]; const domain = tokens[1];
let domainTokens = domain.split("."); const domainTokens = domain.split(".");
domainTokens[domainTokens.length - 2] = maskString(domainTokens[domainTokens.length - 2]); domainTokens[domainTokens.length - 2] = maskString(domainTokens[domainTokens.length - 2]);
return `${username}@${domainTokens.join(".")}`; return `${username}@${domainTokens.join(".")}`;
@ -802,7 +802,7 @@ export function getTagColor(s) {
} }
export function getTags(tags) { export function getTags(tags) {
let res = []; const res = [];
if (!tags) {return res;} if (!tags) {return res;}
tags.forEach((tag, i) => { tags.forEach((tag, i) => {
res.push( res.push(
@ -840,7 +840,7 @@ export function getFromLink() {
export function scrollToDiv(divId) { export function scrollToDiv(divId) {
if (divId) { if (divId) {
let ele = document.getElementById(divId); const ele = document.getElementById(divId);
if (ele) { if (ele) {
ele.scrollIntoView({behavior: "smooth"}); ele.scrollIntoView({behavior: "smooth"});
} }

View File

@ -38,7 +38,7 @@ class SignupTable extends React.Component {
} }
addRow(table) { addRow(table) {
let row = {name: Setting.getNewRowNameForTable(table, "Please select a signup item"), visible: true, required: true, rule: "None"}; const row = {name: Setting.getNewRowNameForTable(table, "Please select a signup item"), visible: true, required: true, rule: "None"};
if (table === undefined) { if (table === undefined) {
table = []; table = [];
} }

View File

@ -73,7 +73,7 @@ class SyncerEditPage extends React.Component {
updateSyncerField(key, value) { updateSyncerField(key, value) {
value = this.parseSyncerField(key, value); value = this.parseSyncerField(key, value);
let syncer = this.state.syncer; const syncer = this.state.syncer;
syncer[key] = value; syncer[key] = value;
this.setState({ this.setState({
syncer: syncer, syncer: syncer,
@ -119,7 +119,7 @@ class SyncerEditPage extends React.Component {
<Col span={22} > <Col span={22} >
<Select virtual={false} style={{width: "100%"}} value={this.state.syncer.type} onChange={(value => { <Select virtual={false} style={{width: "100%"}} value={this.state.syncer.type} onChange={(value => {
this.updateSyncerField("type", value); this.updateSyncerField("type", value);
let syncer = this.state.syncer; const syncer = this.state.syncer;
syncer["tableColumns"] = Setting.getSyncerTableColumns(this.state.syncer); syncer["tableColumns"] = Setting.getSyncerTableColumns(this.state.syncer);
syncer.table = (value === "Keycloak") ? "user_entity" : this.state.syncer.table; syncer.table = (value === "Keycloak") ? "user_entity" : this.state.syncer.table;
this.setState({ this.setState({
@ -295,7 +295,7 @@ class SyncerEditPage extends React.Component {
} }
submitSyncerEdit(willExist) { submitSyncerEdit(willExist) {
let syncer = Setting.deepCopy(this.state.syncer); const syncer = Setting.deepCopy(this.state.syncer);
SyncerBackend.updateSyncer(this.state.syncer.owner, this.state.syncerName, syncer) SyncerBackend.updateSyncer(this.state.syncer.owner, this.state.syncerName, syncer)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -262,7 +262,7 @@ class SyncerListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.type !== undefined && params.type !== null) { if (params.type !== undefined && params.type !== null) {
field = "type"; field = "type";
value = params.type; value = params.type;

View File

@ -38,7 +38,7 @@ class SyncerTableColumnTable extends React.Component {
} }
addRow(table) { addRow(table) {
let row = {name: `column${table.length}`, type: "string", values: []}; const row = {name: `column${table.length}`, type: "string", values: []};
if (table === undefined) { if (table === undefined) {
table = []; table = [];
} }

View File

@ -43,7 +43,7 @@ export function connectSmtpServer(provider) {
} }
function testEmailProvider(provider, email = "") { function testEmailProvider(provider, email = "") {
let emailForm = { const emailForm = {
title: provider.title, title: provider.title,
content: provider.content, content: provider.content,
sender: provider.displayName, sender: provider.displayName,

View File

@ -52,7 +52,7 @@ class TokenEditPage extends React.Component {
updateTokenField(key, value) { updateTokenField(key, value) {
value = this.parseTokenField(key, value); value = this.parseTokenField(key, value);
let token = this.state.token; const token = this.state.token;
token[key] = value; token[key] = value;
this.setState({ this.setState({
token: token, token: token,
@ -164,7 +164,7 @@ class TokenEditPage extends React.Component {
} }
submitTokenEdit(willExist) { submitTokenEdit(willExist) {
let token = Setting.deepCopy(this.state.token); const token = Setting.deepCopy(this.state.token);
TokenBackend.updateToken(this.state.token.owner, this.state.tokenName, token) TokenBackend.updateToken(this.state.token.owner, this.state.tokenName, token)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -230,8 +230,8 @@ class TokenListPage extends BaseListPage {
} }
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; const field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
this.setState({loading: true}); this.setState({loading: true});
TokenBackend.getTokens("admin", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) TokenBackend.getTokens("admin", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => { .then((res) => {

View File

@ -36,7 +36,7 @@ class UrlTable extends React.Component {
} }
addRow(table) { addRow(table) {
let row = ""; const row = "";
if (table === undefined) { if (table === undefined) {
table = []; table = [];
} }

View File

@ -110,7 +110,7 @@ class UserEditPage extends React.Component {
updateUserField(key, value) { updateUserField(key, value) {
value = this.parseUserField(key, value); value = this.parseUserField(key, value);
let user = this.state.user; const user = this.state.user;
user[key] = value; user[key] = value;
this.setState({ this.setState({
user: user, user: user,
@ -583,7 +583,7 @@ class UserEditPage extends React.Component {
} }
submitUserEdit(willExist) { submitUserEdit(willExist) {
let user = Setting.deepCopy(this.state.user); const user = Setting.deepCopy(this.state.user);
UserBackend.updateUser(this.state.organizationName, this.state.userName, user) UserBackend.updateUser(this.state.organizationName, this.state.userName, user)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -131,9 +131,9 @@ class UserListPage extends BaseListPage {
renderTable(users) { renderTable(users) {
// transfer country code to name based on selected language // transfer country code to name based on selected language
var countries = require("i18n-iso-countries"); const countries = require("i18n-iso-countries");
countries.registerLocale(require("i18n-iso-countries/langs/" + i18next.language + ".json")); countries.registerLocale(require("i18n-iso-countries/langs/" + i18next.language + ".json"));
for (var index in users) { for (const index in users) {
users[index].region = countries.getName(users[index].region, i18next.language, {select: "official"}); users[index].region = countries.getName(users[index].region, i18next.language, {select: "official"});
} }
@ -368,8 +368,8 @@ class UserListPage extends BaseListPage {
} }
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; const field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
this.setState({loading: true}); this.setState({loading: true});
if (this.state.organizationName === undefined) { if (this.state.organizationName === undefined) {
UserBackend.getGlobalUsers(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) UserBackend.getGlobalUsers(params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)

View File

@ -133,7 +133,7 @@ class WebhookEditPage extends React.Component {
updateWebhookField(key, value) { updateWebhookField(key, value) {
value = this.parseWebhookField(key, value); value = this.parseWebhookField(key, value);
let webhook = this.state.webhook; const webhook = this.state.webhook;
webhook[key] = value; webhook[key] = value;
this.setState({ this.setState({
webhook: webhook, webhook: webhook,
@ -141,7 +141,7 @@ class WebhookEditPage extends React.Component {
} }
renderWebhook() { renderWebhook() {
let preview = Setting.deepCopy(previewTemplate); const preview = Setting.deepCopy(previewTemplate);
if (this.state.webhook.isUserExtended) { if (this.state.webhook.isUserExtended) {
preview["extendedUser"] = userTemplate; preview["extendedUser"] = userTemplate;
} }
@ -293,7 +293,7 @@ class WebhookEditPage extends React.Component {
} }
submitWebhookEdit(willExist) { submitWebhookEdit(willExist) {
let webhook = Setting.deepCopy(this.state.webhook); const webhook = Setting.deepCopy(this.state.webhook);
WebhookBackend.updateWebhook(this.state.webhook.owner, this.state.webhookName, webhook) WebhookBackend.updateWebhook(this.state.webhook.owner, this.state.webhookName, webhook)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -36,7 +36,7 @@ class WebhookHeaderTable extends React.Component {
} }
addRow(table) { addRow(table) {
let row = {name: `header-${table.length}`, value: `value-${table.length}`}; const row = {name: `header-${table.length}`, value: `value-${table.length}`};
if (table === undefined) { if (table === undefined) {
table = []; table = [];
} }

View File

@ -227,7 +227,7 @@ class WebhookListPage extends BaseListPage {
fetch = (params = {}) => { fetch = (params = {}) => {
let field = params.searchedColumn, value = params.searchText; let field = params.searchedColumn, value = params.searchText;
let sortField = params.sortField, sortOrder = params.sortOrder; const sortField = params.sortField, sortOrder = params.sortOrder;
if (params.contentType !== undefined && params.contentType !== null) { if (params.contentType !== undefined && params.contentType !== null) {
field = "contentType"; field = "contentType";
value = params.contentType; value = params.contentType;

View File

@ -77,7 +77,7 @@ class AuthCallback extends React.Component {
UNSAFE_componentWillMount() { UNSAFE_componentWillMount() {
const params = new URLSearchParams(this.props.location.search); const params = new URLSearchParams(this.props.location.search);
let isSteam = params.get("openid.mode"); const isSteam = params.get("openid.mode");
let code = params.get("code"); let code = params.get("code");
// WeCom returns "auth_code=xxx" instead of "code=xxx" // WeCom returns "auth_code=xxx" instead of "code=xxx"
if (code === null) { if (code === null) {
@ -98,7 +98,7 @@ class AuthCallback extends React.Component {
const method = innerParams.get("method"); const method = innerParams.get("method");
const samlRequest = innerParams.get("SAMLRequest"); const samlRequest = innerParams.get("SAMLRequest");
let redirectUri = `${window.location.origin}/callback`; const redirectUri = `${window.location.origin}/callback`;
const body = { const body = {
type: this.getResponseType(), type: this.getResponseType(),

View File

@ -40,7 +40,7 @@ class CasLogout extends React.Component {
if (res.status === "ok") { if (res.status === "ok") {
Setting.showMessage("success", "Logged out successfully"); Setting.showMessage("success", "Logged out successfully");
this.props.clearAccount(); this.props.clearAccount();
let redirectUri = res.data2; const redirectUri = res.data2;
if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") { if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") {
Setting.goToLink(redirectUri); Setting.goToLink(redirectUri);
} else if (params.has("service")) { } else if (params.has("service")) {

View File

@ -176,7 +176,7 @@ class ForgetPage extends React.Component {
onFinishFailed(values, errorFields) {} onFinishFailed(values, errorFields) {}
renderOptions() { renderOptions() {
let options = []; const options = [];
if (this.state.phone !== "") { if (this.state.phone !== "") {
options.push( options.push(

View File

@ -152,8 +152,8 @@ class LoginPage extends React.Component {
Util.showMessage("success", msg); Util.showMessage("success", msg);
if (casParams.service !== "") { if (casParams.service !== "") {
let st = res.data; const st = res.data;
let newUrl = new URL(casParams.service); const newUrl = new URL(casParams.service);
newUrl.searchParams.append("ticket", st); newUrl.searchParams.append("ticket", st);
window.location.href = newUrl.toString(); window.location.href = newUrl.toString();
} }
@ -250,12 +250,12 @@ class LoginPage extends React.Component {
getSamlUrl(provider) { getSamlUrl(provider) {
const params = new URLSearchParams(this.props.location.search); const params = new URLSearchParams(this.props.location.search);
let clientId = params.get("client_id"); const clientId = params.get("client_id");
let application = params.get("state"); const application = params.get("state");
let realRedirectUri = params.get("redirect_uri"); const realRedirectUri = params.get("redirect_uri");
let redirectUri = `${window.location.origin}/callback/saml`; const redirectUri = `${window.location.origin}/callback/saml`;
let providerName = provider.name; const providerName = provider.name;
let relayState = `${clientId}&${application}&${providerName}&${realRedirectUri}&${redirectUri}`; const relayState = `${clientId}&${application}&${providerName}&${realRedirectUri}&${redirectUri}`;
AuthBackend.getSamlLogin(`${provider.owner}/${providerName}`, btoa(relayState)).then((res) => { AuthBackend.getSamlLogin(`${provider.owner}/${providerName}`, btoa(relayState)).then((res) => {
if (res.data2 === "POST") { if (res.data2 === "POST") {
document.write(res.data); document.write(res.data);
@ -507,20 +507,20 @@ class LoginPage extends React.Component {
if (this.props.account === undefined || this.props.account === null) { if (this.props.account === undefined || this.props.account === null) {
return null; return null;
} }
let application = this.getApplicationObj(); const application = this.getApplicationObj();
if (this.props.account.owner !== application.organization) { if (this.props.account.owner !== application.organization) {
return null; return null;
} }
const params = new URLSearchParams(this.props.location.search); const params = new URLSearchParams(this.props.location.search);
let silentSignin = params.get("silentSignin"); const silentSignin = params.get("silentSignin");
if (silentSignin !== null) { if (silentSignin !== null) {
if (window !== window.parent) { if (window !== window.parent) {
const message = {tag: "Casdoor", type: "SilentSignin", data: "signing-in"}; const message = {tag: "Casdoor", type: "SilentSignin", data: "signing-in"};
window.parent.postMessage(message, "*"); window.parent.postMessage(message, "*");
} }
let values = {}; const values = {};
values["application"] = this.state.application.name; values["application"] = this.state.application.name;
this.onFinish(values); this.onFinish(values);
} }
@ -535,7 +535,7 @@ class LoginPage extends React.Component {
</div> </div>
<br /> <br />
<SelfLoginButton account={this.props.account} onClick={() => { <SelfLoginButton account={this.props.account} onClick={() => {
let values = {}; const values = {};
values["application"] = this.state.application.name; values["application"] = this.state.application.name;
this.onFinish(values); this.onFinish(values);
}} /> }} />
@ -554,7 +554,7 @@ class LoginPage extends React.Component {
return; return;
} }
let application = this.getApplicationObj(); const application = this.getApplicationObj();
return fetch(`${Setting.ServerUrl}/api/webauthn/signin/begin?owner=${application.organization}&name=${username}`, { return fetch(`${Setting.ServerUrl}/api/webauthn/signin/begin?owner=${application.organization}&name=${username}`, {
method: "GET", method: "GET",
credentials: "include", credentials: "include",
@ -576,11 +576,11 @@ class LoginPage extends React.Component {
}); });
}) })
.then((assertion) => { .then((assertion) => {
let authData = assertion.response.authenticatorData; const authData = assertion.response.authenticatorData;
let clientDataJSON = assertion.response.clientDataJSON; const clientDataJSON = assertion.response.clientDataJSON;
let rawId = assertion.rawId; const rawId = assertion.rawId;
let sig = assertion.response.signature; const sig = assertion.response.signature;
let userHandle = assertion.response.userHandle; const userHandle = assertion.response.userHandle;
return fetch(`${Setting.ServerUrl}/api/webauthn/signin/finish`, { return fetch(`${Setting.ServerUrl}/api/webauthn/signin/finish`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -611,7 +611,7 @@ class LoginPage extends React.Component {
} }
renderPasswordOrCodeInput() { renderPasswordOrCodeInput() {
let application = this.getApplicationObj(); const application = this.getApplicationObj();
if (this.state.loginMethod === "password") { if (this.state.loginMethod === "password") {
return this.state.isCodeSignin ? ( return this.state.isCodeSignin ? (
<Form.Item <Form.Item
@ -640,7 +640,7 @@ class LoginPage extends React.Component {
} }
renderMethodChoiceBox() { renderMethodChoiceBox() {
let application = this.getApplicationObj(); const application = this.getApplicationObj();
if (application.enableWebAuthn) { if (application.enableWebAuthn) {
return ( return (
<div> <div>

View File

@ -81,7 +81,7 @@ class PromptPage extends React.Component {
updateUserField(key, value) { updateUserField(key, value) {
value = this.parseUserField(key, value); value = this.parseUserField(key, value);
let user = this.state.user; const user = this.state.user;
user[key] = value; user[key] = value;
this.setState({ this.setState({
user: user, user: user,
@ -163,7 +163,7 @@ class PromptPage extends React.Component {
} }
submitUserEdit(isFinal) { submitUserEdit(isFinal) {
let user = Setting.deepCopy(this.state.user); const user = Setting.deepCopy(this.state.user);
UserBackend.updateUser(this.state.user.owner, this.state.user.name, user) UserBackend.updateUser(this.state.user.owner, this.state.user.name, user)
.then((res) => { .then((res) => {
if (res.msg === "") { if (res.msg === "") {

View File

@ -65,7 +65,7 @@ class ResultPage extends React.Component {
subTitle={i18next.t("signup:Please click the below button to sign in")} subTitle={i18next.t("signup:Please click the below button to sign in")}
extra={[ extra={[
<Button type="primary" key="login" onClick={() => { <Button type="primary" key="login" onClick={() => {
let linkInStorage = sessionStorage.getItem("signinUrl"); const linkInStorage = sessionStorage.getItem("signinUrl");
if (linkInStorage !== null && linkInStorage !== "") { if (linkInStorage !== null && linkInStorage !== "") {
Setting.goToLink(linkInStorage); Setting.goToLink(linkInStorage);
} else { } else {

View File

@ -47,8 +47,8 @@ class SamlCallback extends React.Component {
UNSAFE_componentWillMount() { UNSAFE_componentWillMount() {
const params = new URLSearchParams(this.props.location.search); const params = new URLSearchParams(this.props.location.search);
let relayState = params.get("relayState"); const relayState = params.get("relayState");
let samlResponse = params.get("samlResponse"); const samlResponse = params.get("samlResponse");
const messages = atob(relayState).split("&"); const messages = atob(relayState).split("&");
const clientId = messages[0]; const clientId = messages[0];
const applicationName = messages[1] === "null" ? "app-built-in" : messages[1]; const applicationName = messages[1] === "null" ? "app-built-in" : messages[1];

View File

@ -581,7 +581,7 @@ class SignupPage extends React.Component {
</Button> </Button>
&nbsp;&nbsp;{i18next.t("signup:Have account?")}&nbsp; &nbsp;&nbsp;{i18next.t("signup:Have account?")}&nbsp;
<a onClick={() => { <a onClick={() => {
let linkInStorage = sessionStorage.getItem("signinUrl"); const linkInStorage = sessionStorage.getItem("signinUrl");
if(linkInStorage != null) { if(linkInStorage != null) {
Setting.goToLink(linkInStorage); Setting.goToLink(linkInStorage);
}else{ }else{

View File

@ -43,7 +43,7 @@ export function getUserApplication(owner, name) {
} }
export function updateApplication(owner, name, application) { export function updateApplication(owner, name, application) {
let newApplication = Setting.deepCopy(application); const newApplication = Setting.deepCopy(application);
return fetch(`${Setting.ServerUrl}/api/update-application?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-application?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -52,7 +52,7 @@ export function updateApplication(owner, name, application) {
} }
export function addApplication(application) { export function addApplication(application) {
let newApplication = Setting.deepCopy(application); const newApplication = Setting.deepCopy(application);
newApplication.organization = "built-in"; newApplication.organization = "built-in";
return fetch(`${Setting.ServerUrl}/api/add-application`, { return fetch(`${Setting.ServerUrl}/api/add-application`, {
method: "POST", method: "POST",
@ -62,7 +62,7 @@ export function addApplication(application) {
} }
export function deleteApplication(application) { export function deleteApplication(application) {
let newApplication = Setting.deepCopy(application); const newApplication = Setting.deepCopy(application);
return fetch(`${Setting.ServerUrl}/api/delete-application`, { return fetch(`${Setting.ServerUrl}/api/delete-application`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getCert(owner, name) {
} }
export function updateCert(owner, name, cert) { export function updateCert(owner, name, cert) {
let newCert = Setting.deepCopy(cert); const newCert = Setting.deepCopy(cert);
return fetch(`${Setting.ServerUrl}/api/update-cert?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-cert?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateCert(owner, name, cert) {
} }
export function addCert(cert) { export function addCert(cert) {
let newCert = Setting.deepCopy(cert); const newCert = Setting.deepCopy(cert);
return fetch(`${Setting.ServerUrl}/api/add-cert`, { return fetch(`${Setting.ServerUrl}/api/add-cert`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addCert(cert) {
} }
export function deleteCert(cert) { export function deleteCert(cert) {
let newCert = Setting.deepCopy(cert); const newCert = Setting.deepCopy(cert);
return fetch(`${Setting.ServerUrl}/api/delete-cert`, { return fetch(`${Setting.ServerUrl}/api/delete-cert`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getModel(owner, name) {
} }
export function updateModel(owner, name, model) { export function updateModel(owner, name, model) {
let newModel = Setting.deepCopy(model); const newModel = Setting.deepCopy(model);
return fetch(`${Setting.ServerUrl}/api/update-model?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-model?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateModel(owner, name, model) {
} }
export function addModel(model) { export function addModel(model) {
let newModel = Setting.deepCopy(model); const newModel = Setting.deepCopy(model);
return fetch(`${Setting.ServerUrl}/api/add-model`, { return fetch(`${Setting.ServerUrl}/api/add-model`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addModel(model) {
} }
export function deleteModel(model) { export function deleteModel(model) {
let newModel = Setting.deepCopy(model); const newModel = Setting.deepCopy(model);
return fetch(`${Setting.ServerUrl}/api/delete-model`, { return fetch(`${Setting.ServerUrl}/api/delete-model`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getOrganization(owner, name) {
} }
export function updateOrganization(owner, name, organization) { export function updateOrganization(owner, name, organization) {
let newOrganization = Setting.deepCopy(organization); const newOrganization = Setting.deepCopy(organization);
return fetch(`${Setting.ServerUrl}/api/update-organization?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-organization?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateOrganization(owner, name, organization) {
} }
export function addOrganization(organization) { export function addOrganization(organization) {
let newOrganization = Setting.deepCopy(organization); const newOrganization = Setting.deepCopy(organization);
return fetch(`${Setting.ServerUrl}/api/add-organization`, { return fetch(`${Setting.ServerUrl}/api/add-organization`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addOrganization(organization) {
} }
export function deleteOrganization(organization) { export function deleteOrganization(organization) {
let newOrganization = Setting.deepCopy(organization); const newOrganization = Setting.deepCopy(organization);
return fetch(`${Setting.ServerUrl}/api/delete-organization`, { return fetch(`${Setting.ServerUrl}/api/delete-organization`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getPayment(owner, name) {
} }
export function updatePayment(owner, name, payment) { export function updatePayment(owner, name, payment) {
let newPayment = Setting.deepCopy(payment); const newPayment = Setting.deepCopy(payment);
return fetch(`${Setting.ServerUrl}/api/update-payment?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-payment?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updatePayment(owner, name, payment) {
} }
export function addPayment(payment) { export function addPayment(payment) {
let newPayment = Setting.deepCopy(payment); const newPayment = Setting.deepCopy(payment);
return fetch(`${Setting.ServerUrl}/api/add-payment`, { return fetch(`${Setting.ServerUrl}/api/add-payment`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addPayment(payment) {
} }
export function deletePayment(payment) { export function deletePayment(payment) {
let newPayment = Setting.deepCopy(payment); const newPayment = Setting.deepCopy(payment);
return fetch(`${Setting.ServerUrl}/api/delete-payment`, { return fetch(`${Setting.ServerUrl}/api/delete-payment`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getPermission(owner, name) {
} }
export function updatePermission(owner, name, permission) { export function updatePermission(owner, name, permission) {
let newPermission = Setting.deepCopy(permission); const newPermission = Setting.deepCopy(permission);
return fetch(`${Setting.ServerUrl}/api/update-permission?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-permission?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updatePermission(owner, name, permission) {
} }
export function addPermission(permission) { export function addPermission(permission) {
let newPermission = Setting.deepCopy(permission); const newPermission = Setting.deepCopy(permission);
return fetch(`${Setting.ServerUrl}/api/add-permission`, { return fetch(`${Setting.ServerUrl}/api/add-permission`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addPermission(permission) {
} }
export function deletePermission(permission) { export function deletePermission(permission) {
let newPermission = Setting.deepCopy(permission); const newPermission = Setting.deepCopy(permission);
return fetch(`${Setting.ServerUrl}/api/delete-permission`, { return fetch(`${Setting.ServerUrl}/api/delete-permission`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getProduct(owner, name) {
} }
export function updateProduct(owner, name, product) { export function updateProduct(owner, name, product) {
let newProduct = Setting.deepCopy(product); const newProduct = Setting.deepCopy(product);
return fetch(`${Setting.ServerUrl}/api/update-product?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-product?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateProduct(owner, name, product) {
} }
export function addProduct(product) { export function addProduct(product) {
let newProduct = Setting.deepCopy(product); const newProduct = Setting.deepCopy(product);
return fetch(`${Setting.ServerUrl}/api/add-product`, { return fetch(`${Setting.ServerUrl}/api/add-product`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addProduct(product) {
} }
export function deleteProduct(product) { export function deleteProduct(product) {
let newProduct = Setting.deepCopy(product); const newProduct = Setting.deepCopy(product);
return fetch(`${Setting.ServerUrl}/api/delete-product`, { return fetch(`${Setting.ServerUrl}/api/delete-product`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getProvider(owner, name) {
} }
export function updateProvider(owner, name, provider) { export function updateProvider(owner, name, provider) {
let newProvider = Setting.deepCopy(provider); const newProvider = Setting.deepCopy(provider);
return fetch(`${Setting.ServerUrl}/api/update-provider?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-provider?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateProvider(owner, name, provider) {
} }
export function addProvider(provider) { export function addProvider(provider) {
let newProvider = Setting.deepCopy(provider); const newProvider = Setting.deepCopy(provider);
return fetch(`${Setting.ServerUrl}/api/add-provider`, { return fetch(`${Setting.ServerUrl}/api/add-provider`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addProvider(provider) {
} }
export function deleteProvider(provider) { export function deleteProvider(provider) {
let newProvider = Setting.deepCopy(provider); const newProvider = Setting.deepCopy(provider);
return fetch(`${Setting.ServerUrl}/api/delete-provider`, { return fetch(`${Setting.ServerUrl}/api/delete-provider`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getResource(owner, name) {
} }
export function updateResource(owner, name, resource) { export function updateResource(owner, name, resource) {
let newResource = Setting.deepCopy(resource); const newResource = Setting.deepCopy(resource);
return fetch(`${Setting.ServerUrl}/api/update-resource?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-resource?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateResource(owner, name, resource) {
} }
export function addResource(resource) { export function addResource(resource) {
let newResource = Setting.deepCopy(resource); const newResource = Setting.deepCopy(resource);
return fetch(`${Setting.ServerUrl}/api/add-resource`, { return fetch(`${Setting.ServerUrl}/api/add-resource`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addResource(resource) {
} }
export function deleteResource(resource, provider = "") { export function deleteResource(resource, provider = "") {
let newResource = Setting.deepCopy(resource); const newResource = Setting.deepCopy(resource);
return fetch(`${Setting.ServerUrl}/api/delete-resource?provider=${provider}`, { return fetch(`${Setting.ServerUrl}/api/delete-resource?provider=${provider}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -57,7 +57,7 @@ export function deleteResource(resource, provider = "") {
export function uploadResource(owner, user, tag, parent, fullFilePath, file, provider = "") { export function uploadResource(owner, user, tag, parent, fullFilePath, file, provider = "") {
const application = "app-built-in"; const application = "app-built-in";
let formData = new FormData(); const formData = new FormData();
formData.append("file", file); formData.append("file", file);
return fetch(`${Setting.ServerUrl}/api/upload-resource?owner=${owner}&user=${user}&application=${application}&tag=${tag}&parent=${parent}&fullFilePath=${encodeURIComponent(fullFilePath)}&provider=${provider}`, { return fetch(`${Setting.ServerUrl}/api/upload-resource?owner=${owner}&user=${user}&application=${application}&tag=${tag}&parent=${parent}&fullFilePath=${encodeURIComponent(fullFilePath)}&provider=${provider}`, {
body: formData, body: formData,

View File

@ -29,7 +29,7 @@ export function getRole(owner, name) {
} }
export function updateRole(owner, name, role) { export function updateRole(owner, name, role) {
let newRole = Setting.deepCopy(role); const newRole = Setting.deepCopy(role);
return fetch(`${Setting.ServerUrl}/api/update-role?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-role?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateRole(owner, name, role) {
} }
export function addRole(role) { export function addRole(role) {
let newRole = Setting.deepCopy(role); const newRole = Setting.deepCopy(role);
return fetch(`${Setting.ServerUrl}/api/add-role`, { return fetch(`${Setting.ServerUrl}/api/add-role`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addRole(role) {
} }
export function deleteRole(role) { export function deleteRole(role) {
let newRole = Setting.deepCopy(role); const newRole = Setting.deepCopy(role);
return fetch(`${Setting.ServerUrl}/api/delete-role`, { return fetch(`${Setting.ServerUrl}/api/delete-role`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getSyncer(owner, name) {
} }
export function updateSyncer(owner, name, syncer) { export function updateSyncer(owner, name, syncer) {
let newSyncer = Setting.deepCopy(syncer); const newSyncer = Setting.deepCopy(syncer);
return fetch(`${Setting.ServerUrl}/api/update-syncer?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-syncer?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateSyncer(owner, name, syncer) {
} }
export function addSyncer(syncer) { export function addSyncer(syncer) {
let newSyncer = Setting.deepCopy(syncer); const newSyncer = Setting.deepCopy(syncer);
return fetch(`${Setting.ServerUrl}/api/add-syncer`, { return fetch(`${Setting.ServerUrl}/api/add-syncer`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addSyncer(syncer) {
} }
export function deleteSyncer(syncer) { export function deleteSyncer(syncer) {
let newSyncer = Setting.deepCopy(syncer); const newSyncer = Setting.deepCopy(syncer);
return fetch(`${Setting.ServerUrl}/api/delete-syncer`, { return fetch(`${Setting.ServerUrl}/api/delete-syncer`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -29,7 +29,7 @@ export function getToken(owner, name) {
} }
export function updateToken(owner, name, token) { export function updateToken(owner, name, token) {
let newToken = Setting.deepCopy(token); const newToken = Setting.deepCopy(token);
return fetch(`${Setting.ServerUrl}/api/update-token?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-token?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateToken(owner, name, token) {
} }
export function addToken(token) { export function addToken(token) {
let newToken = Setting.deepCopy(token); const newToken = Setting.deepCopy(token);
return fetch(`${Setting.ServerUrl}/api/add-token`, { return fetch(`${Setting.ServerUrl}/api/add-token`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addToken(token) {
} }
export function deleteToken(token) { export function deleteToken(token) {
let newToken = Setting.deepCopy(token); const newToken = Setting.deepCopy(token);
return fetch(`${Setting.ServerUrl}/api/delete-token`, { return fetch(`${Setting.ServerUrl}/api/delete-token`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -37,7 +37,7 @@ export function getUser(owner, name) {
} }
export function updateUser(owner, name, user) { export function updateUser(owner, name, user) {
let newUser = Setting.deepCopy(user); const newUser = Setting.deepCopy(user);
return fetch(`${Setting.ServerUrl}/api/update-user?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-user?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -46,7 +46,7 @@ export function updateUser(owner, name, user) {
} }
export function addUser(user) { export function addUser(user) {
let newUser = Setting.deepCopy(user); const newUser = Setting.deepCopy(user);
return fetch(`${Setting.ServerUrl}/api/add-user`, { return fetch(`${Setting.ServerUrl}/api/add-user`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -55,7 +55,7 @@ export function addUser(user) {
} }
export function deleteUser(user) { export function deleteUser(user) {
let newUser = Setting.deepCopy(user); const newUser = Setting.deepCopy(user);
return fetch(`${Setting.ServerUrl}/api/delete-user`, { return fetch(`${Setting.ServerUrl}/api/delete-user`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -76,7 +76,7 @@ export function getAffiliationOptions(url, code) {
} }
export function setPassword(userOwner, userName, oldPassword, newPassword) { export function setPassword(userOwner, userName, oldPassword, newPassword) {
let formData = new FormData(); const formData = new FormData();
formData.append("userOwner", userOwner); formData.append("userOwner", userOwner);
formData.append("userName", userName); formData.append("userName", userName);
formData.append("oldPassword", oldPassword); formData.append("oldPassword", oldPassword);
@ -89,7 +89,7 @@ export function setPassword(userOwner, userName, oldPassword, newPassword) {
} }
export function sendCode(checkType, checkId, checkKey, dest, type, applicationId, checkUser) { export function sendCode(checkType, checkId, checkKey, dest, type, applicationId, checkUser) {
let formData = new FormData(); const formData = new FormData();
formData.append("checkType", checkType); formData.append("checkType", checkType);
formData.append("checkId", checkId); formData.append("checkId", checkId);
formData.append("checkKey", checkKey); formData.append("checkKey", checkKey);
@ -113,7 +113,7 @@ export function sendCode(checkType, checkId, checkKey, dest, type, applicationId
} }
export function verifyCaptcha(captchaType, captchaToken, clientSecret) { export function verifyCaptcha(captchaType, captchaToken, clientSecret) {
let formData = new FormData(); const formData = new FormData();
formData.append("captchaType", captchaType); formData.append("captchaType", captchaType);
formData.append("captchaToken", captchaToken); formData.append("captchaToken", captchaToken);
formData.append("clientSecret", clientSecret); formData.append("clientSecret", clientSecret);
@ -137,7 +137,7 @@ export function verifyCaptcha(captchaType, captchaToken, clientSecret) {
} }
export function resetEmailOrPhone(dest, type, code) { export function resetEmailOrPhone(dest, type, code) {
let formData = new FormData(); const formData = new FormData();
formData.append("dest", dest); formData.append("dest", dest);
formData.append("type", type); formData.append("type", type);
formData.append("code", code); formData.append("code", code);

View File

@ -24,7 +24,7 @@ export function registerWebauthnCredential() {
credentialCreationOptions.publicKey.challenge = webAuthnBufferDecode(credentialCreationOptions.publicKey.challenge); credentialCreationOptions.publicKey.challenge = webAuthnBufferDecode(credentialCreationOptions.publicKey.challenge);
credentialCreationOptions.publicKey.user.id = webAuthnBufferDecode(credentialCreationOptions.publicKey.user.id); credentialCreationOptions.publicKey.user.id = webAuthnBufferDecode(credentialCreationOptions.publicKey.user.id);
if (credentialCreationOptions.publicKey.excludeCredentials) { if (credentialCreationOptions.publicKey.excludeCredentials) {
for (var i = 0; i < credentialCreationOptions.publicKey.excludeCredentials.length; i++) { for (let i = 0; i < credentialCreationOptions.publicKey.excludeCredentials.length; i++) {
credentialCreationOptions.publicKey.excludeCredentials[i].id = webAuthnBufferDecode(credentialCreationOptions.publicKey.excludeCredentials[i].id); credentialCreationOptions.publicKey.excludeCredentials[i].id = webAuthnBufferDecode(credentialCreationOptions.publicKey.excludeCredentials[i].id);
} }
} }
@ -33,9 +33,9 @@ export function registerWebauthnCredential() {
}); });
}) })
.then((credential) => { .then((credential) => {
let attestationObject = credential.response.attestationObject; const attestationObject = credential.response.attestationObject;
let clientDataJSON = credential.response.clientDataJSON; const clientDataJSON = credential.response.clientDataJSON;
let rawId = credential.rawId; const rawId = credential.rawId;
return fetch(`${Setting.ServerUrl}/api/webauthn/signup/finish`, { return fetch(`${Setting.ServerUrl}/api/webauthn/signup/finish`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -54,7 +54,7 @@ export function registerWebauthnCredential() {
} }
export function deleteUserWebAuthnCredential(credentialID) { export function deleteUserWebAuthnCredential(credentialID) {
let form = new FormData(); const form = new FormData();
form.append("credentialID", credentialID); form.append("credentialID", credentialID);
return fetch(`${Setting.ServerUrl}/api/webauthn/delete-credential`, { return fetch(`${Setting.ServerUrl}/api/webauthn/delete-credential`, {

View File

@ -29,7 +29,7 @@ export function getWebhook(owner, name) {
} }
export function updateWebhook(owner, name, webhook) { export function updateWebhook(owner, name, webhook) {
let newWebhook = Setting.deepCopy(webhook); const newWebhook = Setting.deepCopy(webhook);
return fetch(`${Setting.ServerUrl}/api/update-webhook?id=${owner}/${encodeURIComponent(name)}`, { return fetch(`${Setting.ServerUrl}/api/update-webhook?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -38,7 +38,7 @@ export function updateWebhook(owner, name, webhook) {
} }
export function addWebhook(webhook) { export function addWebhook(webhook) {
let newWebhook = Setting.deepCopy(webhook); const newWebhook = Setting.deepCopy(webhook);
return fetch(`${Setting.ServerUrl}/api/add-webhook`, { return fetch(`${Setting.ServerUrl}/api/add-webhook`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",
@ -47,7 +47,7 @@ export function addWebhook(webhook) {
} }
export function deleteWebhook(webhook) { export function deleteWebhook(webhook) {
let newWebhook = Setting.deepCopy(webhook); const newWebhook = Setting.deepCopy(webhook);
return fetch(`${Setting.ServerUrl}/api/delete-webhook`, { return fetch(`${Setting.ServerUrl}/api/delete-webhook`, {
method: "POST", method: "POST",
credentials: "include", credentials: "include",

View File

@ -16,10 +16,10 @@ import React, {useEffect} from "react";
export const CaptchaWidget = ({captchaType, subType, siteKey, clientSecret, onChange, clientId2, clientSecret2}) => { export const CaptchaWidget = ({captchaType, subType, siteKey, clientSecret, onChange, clientId2, clientSecret2}) => {
const loadScript = (src) => { const loadScript = (src) => {
var tag = document.createElement("script"); const tag = document.createElement("script");
tag.async = false; tag.async = false;
tag.src = src; tag.src = src;
var body = document.getElementsByTagName("body")[0]; const body = document.getElementsByTagName("body")[0];
body.appendChild(tag); body.appendChild(tag);
}; };

View File

@ -39,8 +39,7 @@ function initLanguage() {
if (Conf.ForceLanguage !== "") { if (Conf.ForceLanguage !== "") {
language = Conf.ForceLanguage; language = Conf.ForceLanguage;
} else { } else {
let userLanguage; const userLanguage = navigator.language;
userLanguage = navigator.language;
switch (userLanguage) { switch (userLanguage) {
case "zh-CN": case "zh-CN":
language = "zh"; language = "zh";