aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-02-18 09:58:58 -0600
committerJP Dillingham <jpdillingham@gmail.com>2022-02-18 09:58:58 -0600
commit14b2b5fbe01fb9eb58eafd6441f9306f8ce73482 (patch)
tree396279be8112a619c1dd0ac07e4861f5a1351b73 /src
parentfccc9c6440af11fd400f3d1dee243d2d18ea1651 (diff)
downloadslskd-14b2b5fbe01fb9eb58eafd6441f9306f8ce73482.tar.gz
re-initialize on login
Diffstat (limited to 'src')
-rw-r--r--src/web/src/components/App.js66
1 files changed, 34 insertions, 32 deletions
diff --git a/src/web/src/components/App.js b/src/web/src/components/App.js
index 35ef736f..3a22e0c8 100644
--- a/src/web/src/components/App.js
+++ b/src/web/src/components/App.js
@@ -48,48 +48,50 @@ class App extends Component {
};
init = async () => {
- try {
- const securityEnabled = await session.getSecurityEnabled();
+ this.setState({ initialized: false }, async () => {
+ try {
+ const securityEnabled = await session.getSecurityEnabled();
+
+ if (!securityEnabled) {
+ console.debug('application security is not enabled, per api call')
+ session.enablePassthrough()
+ }
+
+ if (await session.check()) {
+ const appHub = createApplicationHubConnection();
- if (!securityEnabled) {
- console.debug('application security is not enabled, per api call')
- session.enablePassthrough()
- }
+ appHub.on('state', (state) => {
+ this.setState({ applicationState: state });
+ });
+
+ appHub.on('options', (options) => {
+ this.setState({ applicationOptions: options })
+ })
- if (await session.check()) {
- const appHub = createApplicationHubConnection();
-
- appHub.on('state', (state) => {
- this.setState({ applicationState: state });
- });
+ appHub.onreconnecting(() => this.setState({ error: true, retriesExhausted: false }));
+ appHub.onclose(() => this.setState({ error: true, retriesExhausted: true }));
+ appHub.onreconnected(() => this.setState({ error: false, retriesExhausted: false }));
- appHub.on('options', (options) => {
- this.setState({ applicationOptions: options })
- })
-
- appHub.onreconnecting(() => this.setState({ error: true, retriesExhausted: false }));
- appHub.onclose(() => this.setState({ error: true, retriesExhausted: true }));
- appHub.onreconnected(() => this.setState({ error: false, retriesExhausted: false }));
-
- await appHub.start();
+ await appHub.start();
+ }
+
+ this.setState({
+ error: false,
+ });
+ } catch (err) {
+ console.error(err)
+ this.setState({ error: true, retriesExhausted: true })
+ } finally {
+ this.setState({ initialized: true });
}
-
- this.setState({
- error: false,
- });
- } catch (err) {
- console.error(err)
- this.setState({ error: true, retriesExhausted: true })
- } finally {
- this.setState({ initialized: true });
- }
+ })
}
login = (username, password, rememberMe) => {
this.setState({ login: { ...this.state.login, pending: true, error: undefined }}, async () => {
try {
await session.login({ username, password, rememberMe });
- this.setState({ login: { ...this.state.login, pending: false, error: false }});
+ this.setState({ login: { ...this.state.login, pending: false, error: false }}, () => this.init());
} catch (error) {
this.setState({ login: { ...this.state.login, pending: false, error }});
}