fix for resend, cooldown and a few small fixes
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:pshared/provider/resource.dart';
|
||||
import 'package:pshared/service/account.dart';
|
||||
import 'package:pshared/utils/exception.dart';
|
||||
|
||||
|
||||
class EmailVerificationProvider extends ChangeNotifier {
|
||||
Resource<bool> _resource = Resource(data: null, isLoading: false);
|
||||
String? _token;
|
||||
@@ -16,6 +17,14 @@ class EmailVerificationProvider extends ChangeNotifier {
|
||||
ErrorResponse? get errorResponse =>
|
||||
_resource.error is ErrorResponse ? _resource.error as ErrorResponse : null;
|
||||
int? get errorCode => errorResponse?.code;
|
||||
bool get isTokenAlreadyUsed {
|
||||
final response = errorResponse;
|
||||
if (response == null) return false;
|
||||
if (response.code != 409 || response.error != 'data_conflict') {
|
||||
return false;
|
||||
}
|
||||
return response.details.contains('verification token has already been used');
|
||||
}
|
||||
bool get canResendVerification =>
|
||||
errorCode == 400 || errorCode == 410 || errorCode == 500;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user