mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
Fix some JS warnings.
This commit is contained in:
@ -287,10 +287,12 @@ class App extends Component {
|
|||||||
<Menu onClick={this.handleRightDropdownClick.bind(this)}>
|
<Menu onClick={this.handleRightDropdownClick.bind(this)}>
|
||||||
<Menu.Item key="/account">
|
<Menu.Item key="/account">
|
||||||
<SettingOutlined />
|
<SettingOutlined />
|
||||||
|
|
||||||
{i18next.t("account:My Account")}
|
{i18next.t("account:My Account")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item key="/logout">
|
<Menu.Item key="/logout">
|
||||||
<LogoutOutlined />
|
<LogoutOutlined />
|
||||||
|
|
||||||
{i18next.t("account:Logout")}
|
{i18next.t("account:Logout")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
@ -517,15 +517,15 @@ class UserEditPage extends React.Component {
|
|||||||
}} />
|
}} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
)
|
);
|
||||||
} else if(accountItem.name === "WebAuthn credentials") {
|
} else if(accountItem.name === "WebAuthn credentials") {
|
||||||
return (
|
return (
|
||||||
<Row style={{marginTop: '20px'}} >
|
<Row style={{marginTop: "20px"}} >
|
||||||
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||||
{Setting.getLabel(i18next.t("user:WebAuthn credentials"), i18next.t("user:WebAuthn credentials"))} :
|
{Setting.getLabel(i18next.t("user:WebAuthn credentials"), i18next.t("user:WebAuthn credentials"))} :
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={22} >
|
<Col span={22} >
|
||||||
<WebAuthnCredentialTable table={this.state.user.webauthnCredentials} updateTable={(table)=>{this.updateUserField('webauthnCredentials',table)}} refresh={this.getUser.bind(this)}/>
|
<WebAuthnCredentialTable table={this.state.user.webauthnCredentials} updateTable={(table) => {this.updateUserField("webauthnCredentials", table);}} refresh={this.getUser.bind(this)} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {Button, Table} from 'antd';
|
import {Button, Table} from "antd";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import * as UserWebauthnBackend from "./backend/UserWebauthnBackend";
|
import * as UserWebauthnBackend from "./backend/UserWebauthnBackend";
|
||||||
import * as Setting from "./Setting";
|
import * as Setting from "./Setting";
|
||||||
@ -23,30 +23,34 @@ class WebAuthnCredentialTable extends React.Component {
|
|||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: i18next.t("user:WebAuthn credentials"),
|
title: i18next.t("user:WebAuthn credentials"),
|
||||||
dataIndex: 'ID',
|
dataIndex: "ID",
|
||||||
key: 'ID',
|
key: "ID",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: i18next.t("general:Action"),
|
title: i18next.t("general:Action"),
|
||||||
key: 'action',
|
key: "action",
|
||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
return (
|
return (
|
||||||
<Button style={{marginTop: '5px', marginBottom: '5px', marginRight: '5px'}} type="danger" onClick={() => {this.deleteRow(this.props.table, index)}}>
|
<Button style={{marginTop: "5px", marginBottom: "5px", marginRight: "5px"}} type="danger" onClick={() => {this.deleteRow(this.props.table, index);}}>
|
||||||
{i18next.t("general:Delete")}
|
{i18next.t("general:Delete")}
|
||||||
</Button>
|
</Button>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table scroll={{x: 'max-content'}} rowKey={"ID"} columns={columns} dataSource={this.props.table} size="middle" bordered pagination={false}
|
<Table scroll={{x: "max-content"}} rowKey={"ID"} columns={columns} dataSource={this.props.table} size="middle" bordered pagination={false}
|
||||||
title={() => (
|
title={() => (
|
||||||
<div>
|
<div>
|
||||||
{i18next.t("user:WebAuthn credentials")}
|
{i18next.t("user:WebAuthn credentials")}
|
||||||
<Button style={{marginRight: "5px"}} type="primary" size="small" onClick={() => {this.registerWebAuthn()}}>{i18next.t("general:Add")}</Button>
|
<Button style={{marginRight: "5px"}} type="primary" size="small" onClick={() => {this.registerWebAuthn();}}>
|
||||||
|
{i18next.t("general:Add")}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
/>)
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteRow(table, i) {
|
deleteRow(table, i) {
|
||||||
@ -57,7 +61,7 @@ class WebAuthnCredentialTable extends React.Component {
|
|||||||
registerWebAuthn() {
|
registerWebAuthn() {
|
||||||
UserWebauthnBackend.registerWebauthnCredential().then((res) => {
|
UserWebauthnBackend.registerWebauthnCredential().then((res) => {
|
||||||
if (res.msg === "") {
|
if (res.msg === "") {
|
||||||
Setting.showMessage("success", `Successfully added webauthn credentials`);
|
Setting.showMessage("success", "Successfully added webauthn credentials");
|
||||||
} else {
|
} else {
|
||||||
Setting.showMessage("error", res.msg);
|
Setting.showMessage("error", res.msg);
|
||||||
}
|
}
|
||||||
|
@ -475,14 +475,14 @@ class LoginPage extends React.Component {
|
|||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
htmlType="submit"
|
htmlType="submit"
|
||||||
style={{width: "100%", marginBottom: '5px'}}
|
style={{width: "100%", marginBottom: "5px"}}
|
||||||
disabled={!application.enablePassword}
|
disabled={!application.enablePassword}
|
||||||
>
|
>
|
||||||
{i18next.t("login:Sign In")}
|
{i18next.t("login:Sign In")}
|
||||||
</Button>
|
</Button>
|
||||||
) :
|
) :
|
||||||
(
|
(
|
||||||
<Button type="primary" style={{width: "100%", marginBottom: '5px'}} onClick={() => this.signInWithWebAuthn()}>
|
<Button type="primary" style={{width: "100%", marginBottom: "5px"}} onClick={() => this.signInWithWebAuthn()}>
|
||||||
{i18next.t("login:Sign in with WebAuthn")}
|
{i18next.t("login:Sign in with WebAuthn")}
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
@ -645,7 +645,7 @@ class LoginPage extends React.Component {
|
|||||||
|
|
||||||
return navigator.credentials.get({
|
return navigator.credentials.get({
|
||||||
publicKey: credentialRequestOptions.publicKey
|
publicKey: credentialRequestOptions.publicKey
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
.then((assertion) => {
|
.then((assertion) => {
|
||||||
let authData = assertion.response.authenticatorData;
|
let authData = assertion.response.authenticatorData;
|
||||||
@ -670,7 +670,7 @@ class LoginPage extends React.Component {
|
|||||||
})
|
})
|
||||||
.then(res => res.json()).then((res) => {
|
.then(res => res.json()).then((res) => {
|
||||||
if (res.msg === "") {
|
if (res.msg === "") {
|
||||||
Setting.showMessage("success", `Successfully logged in with webauthn credentials`);
|
Setting.showMessage("success", "Successfully logged in with webauthn credentials");
|
||||||
Setting.goToLink("/");
|
Setting.goToLink("/");
|
||||||
} else {
|
} else {
|
||||||
Setting.showMessage("error", res.msg);
|
Setting.showMessage("error", res.msg);
|
||||||
@ -679,7 +679,7 @@ class LoginPage extends React.Component {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
Setting.showMessage("error", `Failed to connect to server: ${error}`);
|
Setting.showMessage("error", `Failed to connect to server: ${error}`);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPasswordOrCodeInput() {
|
renderPasswordOrCodeInput() {
|
||||||
@ -707,7 +707,7 @@ class LoginPage extends React.Component {
|
|||||||
disabled={!application.enablePassword}
|
disabled={!application.enablePassword}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,14 +716,12 @@ class LoginPage extends React.Component {
|
|||||||
if (application.enableWebAuthn) {
|
if (application.enableWebAuthn) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Tabs defaultActiveKey="password" onChange={(key)=>{this.setState({loginMethod: key})}} centered>
|
<Tabs defaultActiveKey="password" onChange={(key) => {this.setState({loginMethod: key});}} centered>
|
||||||
<TabPane tab={i18next.t("login:Password")} key="password">
|
<TabPane tab={i18next.t("login:Password")} key="password" />
|
||||||
</TabPane>
|
<TabPane tab={"WebAuthn"} key="webAuthn" />
|
||||||
<TabPane tab={"WebAuthn"} key="webAuthn">
|
|
||||||
</TabPane>
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ export function registerWebauthnCredential() {
|
|||||||
}
|
}
|
||||||
return navigator.credentials.create({
|
return navigator.credentials.create({
|
||||||
publicKey: credentialCreationOptions.publicKey
|
publicKey: credentialCreationOptions.publicKey
|
||||||
})
|
});
|
||||||
})
|
})
|
||||||
.then((credential) => {
|
.then((credential) => {
|
||||||
let attestationObject = credential.response.attestationObject;
|
let attestationObject = credential.response.attestationObject;
|
||||||
@ -50,18 +50,19 @@ export function registerWebauthnCredential() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(res => res.json());
|
.then(res => res.json());
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteUserWebAuthnCredential(credentialID) {
|
export function deleteUserWebAuthnCredential(credentialID) {
|
||||||
let form = new FormData()
|
let 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`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: form,
|
body: form,
|
||||||
dataType: "text"
|
dataType: "text"
|
||||||
}).then(res => res.json())
|
}).then(res => res.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base64 to ArrayBuffer
|
// Base64 to ArrayBuffer
|
||||||
@ -74,5 +75,5 @@ export function webAuthnBufferEncode(value) {
|
|||||||
return btoa(String.fromCharCode.apply(null, new Uint8Array(value)))
|
return btoa(String.fromCharCode.apply(null, new Uint8Array(value)))
|
||||||
.replace(/\+/g, "-")
|
.replace(/\+/g, "-")
|
||||||
.replace(/\//g, "_")
|
.replace(/\//g, "_")
|
||||||
.replace(/=/g, "");;
|
.replace(/=/g, "");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user