Finalized OAuth flow, added /profile/{LOGIN} routes, improved home_view with a background

This commit is contained in:
2025-05-14 21:01:47 +02:00
parent ecd2446380
commit 867b617a41
7 changed files with 121 additions and 46 deletions

View File

@@ -1,15 +1,24 @@
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart';
Future<bool> checkToken() async
{
final prefs = await SharedPreferences.getInstance();
return prefs.containsKey('user_token');
if (prefs.containsKey('user_token') == false) { return false; }
final date = DateTime.fromMillisecondsSinceEpoch(prefs.getInt('expiration') ?? 0);
return date.isAfter(DateTime.now());
}
Future<void> saveToken(String token) async
// Future<Map<String, dynamic>> fetchProfileData(String login) async
// {
//
// }
Future<void> saveToken(String token, String refresh, DateTime expiration) async
{
final prefs = await SharedPreferences.getInstance();
await prefs.setString('user_token', token);
await prefs.setString('refresh_token', refresh);
await prefs.setInt('expiration', expiration.millisecondsSinceEpoch);
}
Future<String?> getToken() async