1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 15:38:15 +00:00

get auth token on profile page (#4703)

* get auth token on profile page

* [user settings] web api auth token: fixup & improvement

Co-authored-by: lian <lian@seafile.com>
Co-authored-by: llj <lingjun.li1@gmail.com>
This commit is contained in:
lian
2020-10-23 16:18:03 +08:00
committed by GitHub
parent 711f4f72fb
commit af691dab1b
6 changed files with 63 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
import React from 'react';
import { gettext } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
import { Utils } from '../../utils/utils';
import toaster from '../toast';
class WebAPIAuthToken extends React.Component {
constructor(props) {
super(props);
this.state = {
authToken: '******'
};
}
getAuthToken = () => {
seafileAPI.getAuthTokenBySession().then((res) => {
this.setState({
authToken: res.data.token
});
}).catch((error) => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
}
render() {
const { authToken } = this.state;
return (
<div id="get-auth-token" className="setting-item">
<h3 className="setting-item-heading">{gettext('Web API Auth Token')}</h3>
<div className="d-flex align-items-center">
<input type="text" readOnly={true} value={authToken} className="form-control mr-2 col-sm-5" />
<button className="btn btn-outline-primary" onClick={this.getAuthToken}>{gettext('Get')}</button>
</div>
</div>
);
}
}
export default WebAPIAuthToken;