mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-15 04:12:30 -06:00
WIP - Replaced get_it + injectable with Provider
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import 'package:paperless_mobile/core/type/types.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:paperless_mobile/features/login/model/client_certificate.dart';
|
||||
|
||||
class AuthenticationInformation {
|
||||
static const tokenKey = 'token';
|
||||
static const serverUrlKey = 'serverUrl';
|
||||
static const clientCertificateKey = 'clientCertificate';
|
||||
part 'authentication_information.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class AuthenticationInformation {
|
||||
final String? token;
|
||||
final String serverUrl;
|
||||
final ClientCertificate? clientCertificate;
|
||||
@@ -16,21 +15,6 @@ class AuthenticationInformation {
|
||||
this.clientCertificate,
|
||||
});
|
||||
|
||||
AuthenticationInformation.fromJson(JSON json)
|
||||
: token = json[tokenKey],
|
||||
serverUrl = json[serverUrlKey],
|
||||
clientCertificate = json[clientCertificateKey] != null
|
||||
? ClientCertificate.fromJson(json[clientCertificateKey])
|
||||
: null;
|
||||
|
||||
JSON toJson() {
|
||||
return {
|
||||
tokenKey: token,
|
||||
serverUrlKey: serverUrl,
|
||||
clientCertificateKey: clientCertificate?.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
bool get isValid {
|
||||
return serverUrl.isNotEmpty && (token?.isNotEmpty ?? false);
|
||||
}
|
||||
@@ -48,4 +32,9 @@ class AuthenticationInformation {
|
||||
(removeClientCertificate ? null : this.clientCertificate),
|
||||
);
|
||||
}
|
||||
|
||||
factory AuthenticationInformation.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthenticationInformationFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AuthenticationInformationToJson(this);
|
||||
}
|
||||
|
||||
26
lib/features/login/model/authentication_information.g.dart
Normal file
26
lib/features/login/model/authentication_information.g.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'authentication_information.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AuthenticationInformation _$AuthenticationInformationFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
AuthenticationInformation(
|
||||
token: json['token'] as String?,
|
||||
serverUrl: json['serverUrl'] as String,
|
||||
clientCertificate: json['clientCertificate'] == null
|
||||
? null
|
||||
: ClientCertificate.fromJson(
|
||||
json['clientCertificate'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AuthenticationInformationToJson(
|
||||
AuthenticationInformation instance) =>
|
||||
<String, dynamic>{
|
||||
'token': instance.token,
|
||||
'serverUrl': instance.serverUrl,
|
||||
'clientCertificate': instance.clientCertificate,
|
||||
};
|
||||
Reference in New Issue
Block a user