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