mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-11 17:29:26 +02:00
38 lines
885 B
Dart
38 lines
885 B
Dart
class Session {
|
|
final String id;
|
|
final String userId;
|
|
final String token;
|
|
final DateTime expiresAt;
|
|
final DateTime createdAt;
|
|
|
|
Session({
|
|
required this.id,
|
|
required this.userId,
|
|
required this.token,
|
|
required this.expiresAt,
|
|
required this.createdAt,
|
|
});
|
|
|
|
factory Session.fromMap(Map<String, dynamic> map) {
|
|
return Session(
|
|
id: map['id'] as String,
|
|
userId: map['user_id'] as String,
|
|
token: map['token'] as String,
|
|
expiresAt: DateTime.parse(map['expires_at'] as String),
|
|
createdAt: DateTime.parse(map['created_at'] as String),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'id': id,
|
|
'user_id': userId,
|
|
'token': token,
|
|
'expires_at': expiresAt.toIso8601String(),
|
|
'created_at': createdAt.toIso8601String(),
|
|
};
|
|
}
|
|
|
|
bool get isExpired => DateTime.now().isAfter(expiresAt);
|
|
}
|