mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-13 23:35:46 +00:00
use local cache to store the token
This commit is contained in:
parent
c6c4dead5d
commit
faf09b7d39
@ -11,6 +11,7 @@
|
||||
"connected-react-router": "^4.3.0",
|
||||
"history": "^4.7.2",
|
||||
"prop-types": "^15.6.2",
|
||||
"query-string": "^6.1.0",
|
||||
"react": "^16.4.2",
|
||||
"react-ace": "^6.1.4",
|
||||
"react-copy-to-clipboard": "^5.0.1",
|
||||
|
@ -5,6 +5,7 @@ import {withRouter} from "react-router-dom";
|
||||
|
||||
import routes from '../routes';
|
||||
import queryString from 'query-string';
|
||||
import {put as cachePut, get as cacheGet} from '../services/cache';
|
||||
|
||||
import {
|
||||
initBlockHeader,
|
||||
@ -16,7 +17,14 @@ import {
|
||||
|
||||
class AppContainer extends Component {
|
||||
componentDidMount() {
|
||||
this.props.authenticate(queryString.parse(this.props.location.search).token);
|
||||
let token;
|
||||
if (this.props.location.search) {
|
||||
token = queryString.parse(this.props.location.search).token;
|
||||
cachePut('token', token);
|
||||
} else {
|
||||
token = cacheGet('token');
|
||||
}
|
||||
this.props.authenticate(token);
|
||||
this.props.initBlockHeader();
|
||||
this.props.fetchProcesses();
|
||||
this.props.fetchVersions();
|
||||
|
15
embark-ui/src/services/cache.js
Normal file
15
embark-ui/src/services/cache.js
Normal file
@ -0,0 +1,15 @@
|
||||
export function put(key, value) {
|
||||
window.localStorage.setItem(key, value);
|
||||
}
|
||||
|
||||
export function get(key) {
|
||||
return window.localStorage.getItem(key);
|
||||
}
|
||||
|
||||
export function remove(key) {
|
||||
return window.localStorage.removeItem(key);
|
||||
}
|
||||
|
||||
export function clear() {
|
||||
window.localStorage.clear();
|
||||
}
|
@ -6,9 +6,9 @@ class Authenticator {
|
||||
this.authToken = uuid();
|
||||
|
||||
|
||||
embark.events.on('outputDone', () => {
|
||||
embark.events.once('outputDone', () => {
|
||||
embark.logger.info(__('Access the web backend with the following url: %s',
|
||||
('http://localhost:8000/embark/' + this.authToken).underline));
|
||||
('http://localhost:8000/embark?token=' + this.authToken).underline));
|
||||
});
|
||||
|
||||
embark.registerAPICall(
|
||||
|
Loading…
x
Reference in New Issue
Block a user