mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +00:00
Added Login with email model instead of json encode
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:syncrow_app/utils/helpers/decode_base64.dart';
|
||||
|
||||
class Token {
|
||||
static const String loginAccessToken = 'access_token';
|
||||
@ -30,4 +33,13 @@ class Token {
|
||||
}
|
||||
|
||||
Map<String, String> toJson() => {loginRefreshToken: refreshToken};
|
||||
|
||||
Map<String, dynamic> decodeToken() {
|
||||
final parts = accessToken.split('.');
|
||||
if (parts.length != 3) {
|
||||
throw Exception('invalid access token');
|
||||
}
|
||||
final payload = decodeBase64(parts[1]);
|
||||
return json.decode(payload);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user