✨ Brand new sign in flow
This commit is contained in:
103
lib/models/auth.dart
Normal file
103
lib/models/auth.dart
Normal file
@ -0,0 +1,103 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
|
||||
part 'auth.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class AuthResult {
|
||||
bool isFinished;
|
||||
AuthTicket ticket;
|
||||
|
||||
AuthResult({
|
||||
required this.isFinished,
|
||||
required this.ticket,
|
||||
});
|
||||
|
||||
factory AuthResult.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthResultFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AuthResultToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class AuthTicket {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
String location;
|
||||
String ipAddress;
|
||||
String userAgent;
|
||||
int stepRemain;
|
||||
List<String> claims;
|
||||
List<String> audiences;
|
||||
@JsonKey(defaultValue: [])
|
||||
List<int> factorTrail;
|
||||
String? grantToken;
|
||||
String? accessToken;
|
||||
String? refreshToken;
|
||||
DateTime? expiredAt;
|
||||
DateTime? availableAt;
|
||||
DateTime? lastGrantAt;
|
||||
String? nonce;
|
||||
int? clientId;
|
||||
Account account;
|
||||
int accountId;
|
||||
|
||||
AuthTicket({
|
||||
required this.id,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
required this.location,
|
||||
required this.ipAddress,
|
||||
required this.userAgent,
|
||||
required this.stepRemain,
|
||||
required this.claims,
|
||||
required this.audiences,
|
||||
required this.factorTrail,
|
||||
required this.grantToken,
|
||||
required this.accessToken,
|
||||
required this.refreshToken,
|
||||
required this.expiredAt,
|
||||
required this.availableAt,
|
||||
required this.lastGrantAt,
|
||||
required this.nonce,
|
||||
required this.clientId,
|
||||
required this.account,
|
||||
required this.accountId,
|
||||
});
|
||||
|
||||
factory AuthTicket.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthTicketFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AuthTicketToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class AuthFactor {
|
||||
int id;
|
||||
DateTime createdAt;
|
||||
DateTime updatedAt;
|
||||
DateTime? deletedAt;
|
||||
int type;
|
||||
Map<String, dynamic>? config;
|
||||
Account account;
|
||||
int accountId;
|
||||
|
||||
AuthFactor({
|
||||
required this.id,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.deletedAt,
|
||||
required this.type,
|
||||
required this.config,
|
||||
required this.account,
|
||||
required this.accountId,
|
||||
});
|
||||
|
||||
factory AuthFactor.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthFactorFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AuthFactorToJson(this);
|
||||
}
|
105
lib/models/auth.g.dart
Normal file
105
lib/models/auth.g.dart
Normal file
@ -0,0 +1,105 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'auth.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
AuthResult _$AuthResultFromJson(Map<String, dynamic> json) => AuthResult(
|
||||
isFinished: json['is_finished'] as bool,
|
||||
ticket: AuthTicket.fromJson(json['ticket'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AuthResultToJson(AuthResult instance) =>
|
||||
<String, dynamic>{
|
||||
'is_finished': instance.isFinished,
|
||||
'ticket': instance.ticket.toJson(),
|
||||
};
|
||||
|
||||
AuthTicket _$AuthTicketFromJson(Map<String, dynamic> json) => AuthTicket(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
location: json['location'] as String,
|
||||
ipAddress: json['ip_address'] as String,
|
||||
userAgent: json['user_agent'] as String,
|
||||
stepRemain: (json['step_remain'] as num).toInt(),
|
||||
claims:
|
||||
(json['claims'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
audiences:
|
||||
(json['audiences'] as List<dynamic>).map((e) => e as String).toList(),
|
||||
factorTrail: (json['factor_trail'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
.toList() ??
|
||||
[],
|
||||
grantToken: json['grant_token'] as String?,
|
||||
accessToken: json['access_token'] as String?,
|
||||
refreshToken: json['refresh_token'] as String?,
|
||||
expiredAt: json['expired_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['expired_at'] as String),
|
||||
availableAt: json['available_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['available_at'] as String),
|
||||
lastGrantAt: json['last_grant_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['last_grant_at'] as String),
|
||||
nonce: json['nonce'] as String?,
|
||||
clientId: (json['client_id'] as num?)?.toInt(),
|
||||
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AuthTicketToJson(AuthTicket instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'location': instance.location,
|
||||
'ip_address': instance.ipAddress,
|
||||
'user_agent': instance.userAgent,
|
||||
'step_remain': instance.stepRemain,
|
||||
'claims': instance.claims,
|
||||
'audiences': instance.audiences,
|
||||
'factor_trail': instance.factorTrail,
|
||||
'grant_token': instance.grantToken,
|
||||
'access_token': instance.accessToken,
|
||||
'refresh_token': instance.refreshToken,
|
||||
'expired_at': instance.expiredAt?.toIso8601String(),
|
||||
'available_at': instance.availableAt?.toIso8601String(),
|
||||
'last_grant_at': instance.lastGrantAt?.toIso8601String(),
|
||||
'nonce': instance.nonce,
|
||||
'client_id': instance.clientId,
|
||||
'account': instance.account.toJson(),
|
||||
'account_id': instance.accountId,
|
||||
};
|
||||
|
||||
AuthFactor _$AuthFactorFromJson(Map<String, dynamic> json) => AuthFactor(
|
||||
id: (json['id'] as num).toInt(),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
type: (json['type'] as num).toInt(),
|
||||
config: json['config'] as Map<String, dynamic>?,
|
||||
account: Account.fromJson(json['account'] as Map<String, dynamic>),
|
||||
accountId: (json['account_id'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AuthFactorToJson(AuthFactor instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'created_at': instance.createdAt.toIso8601String(),
|
||||
'updated_at': instance.updatedAt.toIso8601String(),
|
||||
'deleted_at': instance.deletedAt?.toIso8601String(),
|
||||
'type': instance.type,
|
||||
'config': instance.config,
|
||||
'account': instance.account.toJson(),
|
||||
'account_id': instance.accountId,
|
||||
};
|
Reference in New Issue
Block a user