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 {
7373 return user ;
7474 }
7575
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+
7686 clearUser ( ) {
7787 this . user . set ( undefined ) ;
7888 }
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { goto } from ' $app/navigation' ;
3- import { AUTH_SERVICE } from ' $lib/auth/authService.svelte' ;
43 import BranchIndexCard from ' $lib/components/branches/BranchIndexCard.svelte' ;
54 import DashboardLayout from ' $lib/components/dashboard/DashboardLayout.svelte' ;
65 import Table from ' $lib/components/table/Table.svelte' ;
6+ import { USER_SERVICE } from ' $lib/user/userService' ;
77 import { inject } from ' @gitbutler/core/context' ;
88 import { getBranchReviewsForRepository } from ' @gitbutler/shared/branches/branchesPreview.svelte' ;
99 import { BranchStatus } from ' @gitbutler/shared/branches/types' ;
1414 import { Button , Select , SelectItem } from ' @gitbutler/ui' ;
1515
1616 // Get authentication service and check if user is logged in
17- const authService = inject (AUTH_SERVICE );
1817 const routes = inject (WEB_ROUTES_SERVICE );
18+ const userService = inject (USER_SERVICE );
19+ const user = userService .user ;
1920
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
2122 $effect (() => {
22- if (! authService . token . current ) {
23+ if ($user === undefined ) {
2324 goto (routes .homePath ());
2425 }
2526 });
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { goto } from ' $app/navigation' ;
3- import { AUTH_SERVICE } from ' $lib/auth/authService.svelte ' ;
3+ import { USER_SERVICE } from ' $lib/user/userService ' ;
44 import { inject } from ' @gitbutler/core/context' ;
55 import { eventTimeStamp } from ' @gitbutler/shared/branches/utils' ;
66 import Loading from ' @gitbutler/shared/network/Loading.svelte' ;
1111 import type { Rule } from ' @gitbutler/shared/rules/types' ;
1212
1313 // Get authentication service and check if user is logged in
14- const authService = inject (AUTH_SERVICE );
1514 const routes = inject (WEB_ROUTES_SERVICE );
15+ const userService = inject (USER_SERVICE );
16+ const user = userService .user ;
1617
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
1819 $effect (() => {
19- if (! authService . token . current ) {
20+ if ($user === undefined ) {
2021 goto (routes .homePath ());
2122 }
2223 });
You can’t perform that action at this time.
0 commit comments