Skip to content

Commit 13d59eb

Browse files
david-kalmakoffjmattheis
authored andcommitted
bug: fixed router navigating to homepage on page loads
1 parent b08b5ae commit 13d59eb

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

ui/src/CurrentUser.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class CurrentUser {
1515
@observable
1616
public loggedIn = false;
1717
@observable
18-
public authenticating = false;
18+
public authenticating = true;
1919
@observable
2020
public user: IUser = {name: 'unknown', admin: false, id: -1};
2121
@observable
@@ -80,17 +80,11 @@ export class CurrentUser {
8080
.then((resp: AxiosResponse<IClient>) => {
8181
this.snack(`A client named '${name}' was created for your session.`);
8282
this.setToken(resp.data.token);
83-
this.tryAuthenticate()
84-
.then(() => {
85-
this.authenticating = false;
86-
this.loggedIn = true;
87-
})
88-
.catch(() => {
89-
this.authenticating = false;
90-
console.log(
91-
'create client succeeded, but authenticated with given token failed'
92-
);
93-
});
83+
this.tryAuthenticate().catch(() => {
84+
console.log(
85+
'create client succeeded, but authenticated with given token failed'
86+
);
87+
});
9488
})
9589
.catch(() => {
9690
this.authenticating = false;
@@ -100,6 +94,7 @@ export class CurrentUser {
10094

10195
public tryAuthenticate = async (): Promise<AxiosResponse<IUser>> => {
10296
if (this.token() === '') {
97+
this.authenticating = false;
10398
return Promise.reject();
10499
}
105100

@@ -111,11 +106,13 @@ export class CurrentUser {
111106
.then((passThrough) => {
112107
this.user = passThrough.data;
113108
this.loggedIn = true;
109+
this.authenticating = false;
114110
this.connectionErrorMessage = null;
115111
this.reconnectTime = 7500;
116112
return passThrough;
117113
})
118114
.catch((error: AxiosError) => {
115+
this.authenticating = false;
119116
if (!error || !error.response) {
120117
this.connectionError('No network connection or server unavailable.');
121118
return Promise.reject(error);

ui/src/tests/user.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const $dialog = selector.form('#add-edit-user-dialog');
2424

2525
describe('User', () => {
2626
it('does login', async () => await auth.login(page));
27-
it('navigates to users', async () => {
28-
await page.click('#navigate-users');
27+
it('navigates to users through window location', async () => {
28+
await page.goto(gotify.url + '/#/users');
2929
await waitForExists(page, selector.heading(), 'Users');
3030
});
3131
it('has changed url', async () => {

0 commit comments

Comments
 (0)