Finalized OAuth flow, added /profile/{LOGIN} routes, improved home_view with a background
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user