mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
Initialized Auth pages for future work
Implemented Login functionality
This commit is contained in:
31
lib/features/auth/model/token.dart
Normal file
31
lib/features/auth/model/token.dart
Normal file
@ -0,0 +1,31 @@
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
class Token {
|
||||
static const String loginAccessToken = 'access_token';
|
||||
static const String loginRefreshToken = 'refreshToken';
|
||||
|
||||
final String accessToken;
|
||||
final String refreshToken;
|
||||
|
||||
Token.emptyConstructor()
|
||||
: accessToken = '',
|
||||
refreshToken = '';
|
||||
|
||||
Token(
|
||||
this.accessToken,
|
||||
this.refreshToken,
|
||||
);
|
||||
|
||||
Token.refreshToken(this.refreshToken) : accessToken = '';
|
||||
|
||||
factory Token.fromJson(Map<String, dynamic> json) {
|
||||
//save token to secure storage
|
||||
var storage = const FlutterSecureStorage();
|
||||
storage.write(key: loginAccessToken, value: json[loginAccessToken] ?? '');
|
||||
|
||||
//create token object ?
|
||||
return Token(json[loginAccessToken] ?? '', json[loginRefreshToken] ?? '');
|
||||
}
|
||||
|
||||
Map<String, String> toJson() => {loginRefreshToken: refreshToken};
|
||||
}
|
Reference in New Issue
Block a user