mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
		
			681 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			681 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
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");
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 |