mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
Transfer repository from Gitlab
This commit is contained in:
parent
af2efbdbbd
commit
568cc243f0
177 changed files with 13300 additions and 0 deletions
22
mobile/lib/routing/auth_guard.dart
Normal file
22
mobile/lib/routing/auth_guard.dart
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:immich_mobile/shared/services/network.service.dart';
|
||||
|
||||
class AuthGuard extends AutoRouteGuard {
|
||||
final NetworkService _networkService = NetworkService();
|
||||
|
||||
@override
|
||||
void onNavigation(NavigationResolver resolver, StackRouter router) async {
|
||||
try {
|
||||
var res = await _networkService.postRequest(url: 'auth/validateToken');
|
||||
var jsonReponse = jsonDecode(res.toString());
|
||||
if (jsonReponse['authStatus']) {
|
||||
resolver.next(true);
|
||||
}
|
||||
} catch (e) {
|
||||
router.removeUntil((route) => route.name == "LoginRoute");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue