File tree Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Expand file tree Collapse file tree 3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,16 @@ export class UserService {
73
73
return user ;
74
74
}
75
75
76
+ async refreshUser ( ) {
77
+ try {
78
+ const user = await this . fetchUser ( ) ;
79
+ this . user . set ( user ) ;
80
+ this . error . set ( undefined ) ;
81
+ } catch ( error ) {
82
+ this . error . set ( error ) ;
83
+ }
84
+ }
85
+
76
86
clearUser ( ) {
77
87
this . user . set ( undefined ) ;
78
88
}
Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import { goto } from ' $app/navigation' ;
3
- import { AUTH_SERVICE } from ' $lib/auth/authService.svelte' ;
4
3
import BranchIndexCard from ' $lib/components/branches/BranchIndexCard.svelte' ;
5
4
import DashboardLayout from ' $lib/components/dashboard/DashboardLayout.svelte' ;
6
5
import Table from ' $lib/components/table/Table.svelte' ;
6
+ import { USER_SERVICE } from ' $lib/user/userService' ;
7
7
import { getBranchReviewsForRepository } from ' @gitbutler/shared/branches/branchesPreview.svelte' ;
8
8
import { BranchStatus } from ' @gitbutler/shared/branches/types' ;
9
9
import { inject } from ' @gitbutler/shared/context' ;
14
14
import { Button , Select , SelectItem } from ' @gitbutler/ui' ;
15
15
16
16
// Get authentication service and check if user is logged in
17
- const authService = inject (AUTH_SERVICE );
18
17
const routes = inject (WEB_ROUTES_SERVICE );
18
+ const userService = inject (USER_SERVICE );
19
+ const user = userService .user ;
19
20
20
- // If there is no token (user not logged in), redirect to home
21
+ // If there is no user (user not logged in), redirect to home
21
22
$effect (() => {
22
- if (! authService . token . current ) {
23
+ if ($user === undefined ) {
23
24
goto (routes .homePath ());
24
25
}
25
26
});
Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import { goto } from ' $app/navigation' ;
3
- import { AUTH_SERVICE } from ' $lib/auth/authService.svelte ' ;
3
+ import { USER_SERVICE } from ' $lib/user/userService ' ;
4
4
import { eventTimeStamp } from ' @gitbutler/shared/branches/utils' ;
5
5
import { inject } from ' @gitbutler/shared/context' ;
6
6
import Loading from ' @gitbutler/shared/network/Loading.svelte' ;
11
11
import type { Rule } from ' @gitbutler/shared/rules/types' ;
12
12
13
13
// Get authentication service and check if user is logged in
14
- const authService = inject (AUTH_SERVICE );
15
14
const routes = inject (WEB_ROUTES_SERVICE );
15
+ const userService = inject (USER_SERVICE );
16
+ const user = userService .user ;
16
17
17
- // If there is no token (user not logged in), redirect to home
18
+ // If there is no user (user not logged in), redirect to home
18
19
$effect (() => {
19
- if (! authService . token . current ) {
20
+ if ($user === undefined ) {
20
21
goto (routes .homePath ());
21
22
}
22
23
});
You can’t perform that action at this time.
0 commit comments