fix: rework core and entities
This commit is contained in:
parent
2f572db4a4
commit
d2d8acdafb
19
packages/wyatt_authentication_bloc/lib/src/core/core.dart
Normal file
19
packages/wyatt_authentication_bloc/lib/src/core/core.dart
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2022 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
export 'enums/enums.dart';
|
||||
export 'exceptions/exceptions.dart';
|
||||
export 'utils/utils.dart';
|
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2022 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
enum AuthenticationStatus {
|
||||
unknown,
|
||||
authenticated,
|
||||
unauthenticated,
|
||||
}
|
@ -1,20 +1,17 @@
|
||||
// Copyright (C) 2022 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
enum AuthCubitStatus {
|
||||
started,
|
||||
stoped,
|
||||
}
|
||||
export 'authentication_status.dart';
|
@ -14,13 +14,18 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
abstract class AuthenticationFailureInterface implements Exception {
|
||||
String code;
|
||||
String message;
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
|
||||
AuthenticationFailureInterface(this.code, this.message);
|
||||
part 'exceptions_firebase.dart';
|
||||
|
||||
abstract class AuthenticationFailureInterface extends AppException
|
||||
implements Exception {
|
||||
String code;
|
||||
String msg;
|
||||
|
||||
AuthenticationFailureInterface(this.code, this.msg);
|
||||
AuthenticationFailureInterface.fromCode(this.code)
|
||||
: message = 'An unknown error occurred.';
|
||||
: msg = 'An unknown error occurred.';
|
||||
}
|
||||
|
||||
/// {@template apply_action_code_failure}
|
||||
@ -29,7 +34,7 @@ abstract class AuthenticationFailureInterface implements Exception {
|
||||
abstract class ApplyActionCodeFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro apply_action_code_failure}
|
||||
ApplyActionCodeFailureInterface(super.code, super.message);
|
||||
ApplyActionCodeFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro apply_action_code_failure}
|
||||
ApplyActionCodeFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -41,7 +46,7 @@ abstract class ApplyActionCodeFailureInterface
|
||||
abstract class SignUpWithEmailAndPasswordFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_up_with_email_and_password_failure}
|
||||
SignUpWithEmailAndPasswordFailureInterface(super.code, super.message);
|
||||
SignUpWithEmailAndPasswordFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_up_with_email_and_password_failure}
|
||||
SignUpWithEmailAndPasswordFailureInterface.fromCode(super.code)
|
||||
@ -54,7 +59,7 @@ abstract class SignUpWithEmailAndPasswordFailureInterface
|
||||
abstract class FetchSignInMethodsForEmailFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro fetch_sign_in_methods_failure}
|
||||
FetchSignInMethodsForEmailFailureInterface(super.code, super.message);
|
||||
FetchSignInMethodsForEmailFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro fetch_sign_in_methods_failure}
|
||||
FetchSignInMethodsForEmailFailureInterface.fromCode(super.code)
|
||||
@ -67,7 +72,7 @@ abstract class FetchSignInMethodsForEmailFailureInterface
|
||||
abstract class SignInWithCredentialFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_in_with_credential_failure}
|
||||
SignInWithCredentialFailureInterface(super.code, super.message);
|
||||
SignInWithCredentialFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_in_with_credential_failure}
|
||||
SignInWithCredentialFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -79,7 +84,7 @@ abstract class SignInWithCredentialFailureInterface
|
||||
abstract class SignInAnonymouslyFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_in_anonymously_failure}
|
||||
SignInAnonymouslyFailureInterface(super.code, super.message);
|
||||
SignInAnonymouslyFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_in_anonymously_failure}
|
||||
SignInAnonymouslyFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -91,7 +96,7 @@ abstract class SignInAnonymouslyFailureInterface
|
||||
abstract class SignInWithGoogleFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_in_with_google_failure}
|
||||
SignInWithGoogleFailureInterface(super.code, super.message);
|
||||
SignInWithGoogleFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_in_with_google_failure}
|
||||
SignInWithGoogleFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -103,7 +108,7 @@ abstract class SignInWithGoogleFailureInterface
|
||||
abstract class SignInWithFacebookFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_in_with_facebook_failure}
|
||||
SignInWithFacebookFailureInterface(super.code, super.message);
|
||||
SignInWithFacebookFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_in_with_facebook_failure}
|
||||
SignInWithFacebookFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -115,7 +120,7 @@ abstract class SignInWithFacebookFailureInterface
|
||||
abstract class SignInWithAppleFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_in_with_apple_failure}
|
||||
SignInWithAppleFailureInterface(super.code, super.message);
|
||||
SignInWithAppleFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_in_with_apple_failure}
|
||||
SignInWithAppleFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -127,7 +132,7 @@ abstract class SignInWithAppleFailureInterface
|
||||
abstract class SignInWithTwitterFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_in_with_twitter_failure}
|
||||
SignInWithTwitterFailureInterface(super.code, super.message);
|
||||
SignInWithTwitterFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_in_with_twitter_failure}
|
||||
SignInWithTwitterFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -139,7 +144,7 @@ abstract class SignInWithTwitterFailureInterface
|
||||
abstract class SignInWithEmailLinkFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_in_with_email_link_failure}
|
||||
SignInWithEmailLinkFailureInterface(super.code, super.message);
|
||||
SignInWithEmailLinkFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_in_with_email_link_failure}
|
||||
SignInWithEmailLinkFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -151,7 +156,7 @@ abstract class SignInWithEmailLinkFailureInterface
|
||||
abstract class SignInWithEmailAndPasswordFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_in_with_email_and_password_failure}
|
||||
SignInWithEmailAndPasswordFailureInterface(super.code, super.message);
|
||||
SignInWithEmailAndPasswordFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_in_with_email_and_password_failure}
|
||||
SignInWithEmailAndPasswordFailureInterface.fromCode(super.code)
|
||||
@ -164,7 +169,7 @@ abstract class SignInWithEmailAndPasswordFailureInterface
|
||||
abstract class SendEmailVerificationFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro send_email_verification_failure}
|
||||
SendEmailVerificationFailureInterface(super.code, super.message);
|
||||
SendEmailVerificationFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro send_email_verification_failure}
|
||||
SendEmailVerificationFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -176,7 +181,7 @@ abstract class SendEmailVerificationFailureInterface
|
||||
abstract class SendPasswordResetEmailFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro send_password_reset_email_failure}
|
||||
SendPasswordResetEmailFailureInterface(super.code, super.message);
|
||||
SendPasswordResetEmailFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro send_password_reset_email_failure}
|
||||
SendPasswordResetEmailFailureInterface.fromCode(super.code)
|
||||
@ -189,7 +194,7 @@ abstract class SendPasswordResetEmailFailureInterface
|
||||
abstract class SendSignInLinkEmailFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro send_sign_in_link_email_failure}
|
||||
SendSignInLinkEmailFailureInterface(super.code, super.message);
|
||||
SendSignInLinkEmailFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro send_sign_in_link_email_failure}
|
||||
SendSignInLinkEmailFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -201,7 +206,7 @@ abstract class SendSignInLinkEmailFailureInterface
|
||||
abstract class ConfirmPasswordResetFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro confirm_password_reset_failure}
|
||||
ConfirmPasswordResetFailureInterface(super.code, super.message);
|
||||
ConfirmPasswordResetFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro confirm_password_reset_failure}
|
||||
ConfirmPasswordResetFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -213,7 +218,7 @@ abstract class ConfirmPasswordResetFailureInterface
|
||||
abstract class VerifyPasswordResetCodeFailureInterface
|
||||
extends AuthenticationFailureInterface {
|
||||
/// {@macro verify_password_reset_code_failure}
|
||||
VerifyPasswordResetCodeFailureInterface(super.code, super.message);
|
||||
VerifyPasswordResetCodeFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro verify_password_reset_code_failure}
|
||||
VerifyPasswordResetCodeFailureInterface.fromCode(super.code)
|
||||
@ -225,7 +230,7 @@ abstract class VerifyPasswordResetCodeFailureInterface
|
||||
/// {@endtemplate}
|
||||
abstract class RefreshFailureInterface extends AuthenticationFailureInterface {
|
||||
/// {@macro refresh_failure}
|
||||
RefreshFailureInterface(super.code, super.message);
|
||||
RefreshFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro refresh_failure}
|
||||
RefreshFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
@ -236,7 +241,7 @@ abstract class RefreshFailureInterface extends AuthenticationFailureInterface {
|
||||
/// {@endtemplate}
|
||||
abstract class SignOutFailureInterface extends AuthenticationFailureInterface {
|
||||
/// {@macro sign_out_failure}
|
||||
SignOutFailureInterface(super.code, super.message);
|
||||
SignOutFailureInterface(super.code, super.msg);
|
||||
|
||||
/// {@macro sign_out_failure}
|
||||
SignOutFailureInterface.fromCode(super.code) : super.fromCode();
|
||||
|
@ -14,133 +14,130 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'package:wyatt_authentication_bloc/src/core/exceptions/exceptions.dart';
|
||||
part of 'exceptions.dart';
|
||||
|
||||
class ApplyActionCodeFailureFirebase extends ApplyActionCodeFailureInterface {
|
||||
ApplyActionCodeFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
ApplyActionCodeFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
ApplyActionCodeFailureFirebase.fromCode(String code) : super.fromCode(code) {
|
||||
switch (code) {
|
||||
case 'expired-action-code':
|
||||
message = 'Action code has expired.';
|
||||
msg = 'Action code has expired.';
|
||||
break;
|
||||
case 'invalid-action-code':
|
||||
message = 'Action code is invalid.';
|
||||
msg = 'Action code is invalid.';
|
||||
break;
|
||||
case 'user-disabled':
|
||||
message =
|
||||
'This user has been disabled. Please contact support for help.';
|
||||
msg = 'This user has been disabled. Please contact support for help.';
|
||||
break;
|
||||
case 'user-not-found':
|
||||
message = 'Email is not found, please create an account.';
|
||||
msg = 'Email is not found, please create an account.';
|
||||
break;
|
||||
|
||||
default:
|
||||
this.code = 'unknown';
|
||||
message = 'An unknown error occurred.';
|
||||
msg = 'An unknown error occurred.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SignUpWithEmailAndPasswordFailureFirebase
|
||||
extends SignUpWithEmailAndPasswordFailureInterface {
|
||||
SignUpWithEmailAndPasswordFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
SignUpWithEmailAndPasswordFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
SignUpWithEmailAndPasswordFailureFirebase.fromCode(String code)
|
||||
: super.fromCode(code) {
|
||||
switch (code) {
|
||||
case 'invalid-email':
|
||||
message = 'The email address is badly formatted.';
|
||||
msg = 'The email address is badly formatted.';
|
||||
break;
|
||||
case 'user-disabled':
|
||||
message =
|
||||
'This user has been disabled. Please contact support for help.';
|
||||
msg = 'This user has been disabled. Please contact support for help.';
|
||||
break;
|
||||
case 'email-already-in-use':
|
||||
message = 'An account already exists for that email.';
|
||||
msg = 'An account already exists for that email.';
|
||||
break;
|
||||
case 'operation-not-allowed':
|
||||
message = 'Operation is not allowed. Please contact support.';
|
||||
msg = 'Operation is not allowed. Please contact support.';
|
||||
break;
|
||||
case 'weak-password':
|
||||
message = 'Please enter a stronger password.';
|
||||
msg = 'Please enter a stronger password.';
|
||||
break;
|
||||
default:
|
||||
this.code = 'unknown';
|
||||
message = 'An unknown error occurred.';
|
||||
msg = 'An unknown error occurred.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FetchSignInMethodsForEmailFailureFirebase
|
||||
extends FetchSignInMethodsForEmailFailureInterface {
|
||||
FetchSignInMethodsForEmailFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
FetchSignInMethodsForEmailFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
FetchSignInMethodsForEmailFailureFirebase.fromCode(String code)
|
||||
: super.fromCode(code) {
|
||||
switch (code) {
|
||||
case 'invalid-email':
|
||||
message = 'The email address is badly formatted.';
|
||||
msg = 'The email address is badly formatted.';
|
||||
break;
|
||||
default:
|
||||
this.code = 'unknown';
|
||||
message = 'An unknown error occurred.';
|
||||
msg = 'An unknown error occurred.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SignInAnonymouslyFailureFirebase
|
||||
extends SignInAnonymouslyFailureInterface {
|
||||
SignInAnonymouslyFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
SignInAnonymouslyFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
SignInAnonymouslyFailureFirebase.fromCode(String code)
|
||||
: super.fromCode(code) {
|
||||
switch (code) {
|
||||
case 'operation-not-allowed':
|
||||
message = 'Operation is not allowed. Please contact support.';
|
||||
msg = 'Operation is not allowed. Please contact support.';
|
||||
break;
|
||||
default:
|
||||
this.code = 'unknown';
|
||||
message = 'An unknown error occurred.';
|
||||
msg = 'An unknown error occurred.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SignInWithCredentialFailureFirebase
|
||||
extends SignInWithCredentialFailureInterface {
|
||||
SignInWithCredentialFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
SignInWithCredentialFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
SignInWithCredentialFailureFirebase.fromCode(String code)
|
||||
: super.fromCode(code) {
|
||||
switch (code) {
|
||||
case 'account-exists-with-different-credential':
|
||||
message = 'Account exists with different credentials.';
|
||||
msg = 'Account exists with different credentials.';
|
||||
break;
|
||||
case 'invalid-credential':
|
||||
message = 'The credential received is malformed or has expired.';
|
||||
msg = 'The credential received is malformed or has expired.';
|
||||
break;
|
||||
case 'operation-not-allowed':
|
||||
message = 'Operation is not allowed. Please contact support.';
|
||||
msg = 'Operation is not allowed. Please contact support.';
|
||||
break;
|
||||
case 'user-disabled':
|
||||
message =
|
||||
'This user has been disabled. Please contact support for help.';
|
||||
msg = 'This user has been disabled. Please contact support for help.';
|
||||
break;
|
||||
case 'user-not-found':
|
||||
message = 'Email is not found, please create an account.';
|
||||
msg = 'Email is not found, please create an account.';
|
||||
break;
|
||||
case 'wrong-password':
|
||||
message = 'Incorrect password, please try again.';
|
||||
msg = 'Incorrect password, please try again.';
|
||||
break;
|
||||
case 'invalid-verification-code':
|
||||
message = 'The credential verification code received is invalid.';
|
||||
msg = 'The credential verification code received is invalid.';
|
||||
break;
|
||||
case 'invalid-verification-id':
|
||||
message = 'The credential verification ID received is invalid.';
|
||||
msg = 'The credential verification ID received is invalid.';
|
||||
break;
|
||||
default:
|
||||
this.code = 'unknown';
|
||||
message = 'An unknown error occurred.';
|
||||
msg = 'An unknown error occurred.';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,130 +145,128 @@ class SignInWithCredentialFailureFirebase
|
||||
class SignInWithGoogleFailureFirebase
|
||||
extends SignInWithCredentialFailureFirebase
|
||||
implements SignInWithGoogleFailureInterface {
|
||||
SignInWithGoogleFailureFirebase([super.code, super.message]);
|
||||
SignInWithGoogleFailureFirebase([super.code, super.msg]);
|
||||
SignInWithGoogleFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
||||
class SignInWithFacebookFailureFirebase
|
||||
extends SignInWithCredentialFailureFirebase
|
||||
implements SignInWithFacebookFailureInterface {
|
||||
SignInWithFacebookFailureFirebase([super.code, super.message]);
|
||||
SignInWithFacebookFailureFirebase([super.code, super.msg]);
|
||||
SignInWithFacebookFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
||||
class SignInWithAppleFailureFirebase extends SignInWithCredentialFailureFirebase
|
||||
implements SignInWithAppleFailureInterface {
|
||||
SignInWithAppleFailureFirebase([super.code, super.message]);
|
||||
SignInWithAppleFailureFirebase([super.code, super.msg]);
|
||||
SignInWithAppleFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
||||
class SignInWithTwitterFailureFirebase
|
||||
extends SignInWithCredentialFailureFirebase
|
||||
implements SignInWithAppleFailureInterface {
|
||||
SignInWithTwitterFailureFirebase([super.code, super.message]);
|
||||
SignInWithTwitterFailureFirebase([super.code, super.msg]);
|
||||
SignInWithTwitterFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
||||
class SignInWithEmailLinkFailureFirebase
|
||||
extends SignInWithEmailLinkFailureInterface {
|
||||
SignInWithEmailLinkFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
SignInWithEmailLinkFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
SignInWithEmailLinkFailureFirebase.fromCode(String code)
|
||||
: super.fromCode(code) {
|
||||
switch (code) {
|
||||
case 'expired-action-code':
|
||||
message = 'Action code has expired.';
|
||||
msg = 'Action code has expired.';
|
||||
break;
|
||||
case 'invalid-email':
|
||||
message = 'Email is not valid or badly formatted.';
|
||||
msg = 'Email is not valid or badly formatted.';
|
||||
break;
|
||||
case 'user-disabled':
|
||||
message =
|
||||
'This user has been disabled. Please contact support for help.';
|
||||
msg = 'This user has been disabled. Please contact support for help.';
|
||||
break;
|
||||
default:
|
||||
this.code = 'unknown';
|
||||
message = 'An unknown error occurred.';
|
||||
msg = 'An unknown error occurred.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SignInWithEmailAndPasswordFailureFirebase
|
||||
extends SignInWithEmailAndPasswordFailureInterface {
|
||||
SignInWithEmailAndPasswordFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
SignInWithEmailAndPasswordFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
SignInWithEmailAndPasswordFailureFirebase.fromCode(String code)
|
||||
: super.fromCode(code) {
|
||||
switch (code) {
|
||||
case 'invalid-email':
|
||||
message = 'Email is not valid or badly formatted.';
|
||||
msg = 'Email is not valid or badly formatted.';
|
||||
break;
|
||||
case 'user-disabled':
|
||||
message =
|
||||
'This user has been disabled. Please contact support for help.';
|
||||
msg = 'This user has been disabled. Please contact support for help.';
|
||||
break;
|
||||
case 'user-not-found':
|
||||
message = 'Email is not found, please create an account.';
|
||||
msg = 'Email is not found, please create an account.';
|
||||
break;
|
||||
case 'wrong-password':
|
||||
message = 'Incorrect password, please try again.';
|
||||
msg = 'Incorrect password, please try again.';
|
||||
break;
|
||||
default:
|
||||
this.code = 'unknown';
|
||||
message = 'An unknown error occurred.';
|
||||
msg = 'An unknown error occurred.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SendEmailVerificationFailureFirebase
|
||||
extends SendEmailVerificationFailureInterface {
|
||||
SendEmailVerificationFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
SendEmailVerificationFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
|
||||
SendEmailVerificationFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
||||
class SendPasswordResetEmailFailureFirebase
|
||||
extends SendPasswordResetEmailFailureInterface {
|
||||
SendPasswordResetEmailFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
SendPasswordResetEmailFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
SendPasswordResetEmailFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
||||
class SendSignInLinkEmailFailureFirebase
|
||||
extends SendSignInLinkEmailFailureInterface {
|
||||
SendSignInLinkEmailFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
SendSignInLinkEmailFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
|
||||
SendSignInLinkEmailFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
||||
class ConfirmPasswordResetFailureFirebase
|
||||
extends ConfirmPasswordResetFailureInterface {
|
||||
ConfirmPasswordResetFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
ConfirmPasswordResetFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
|
||||
ConfirmPasswordResetFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
||||
class VerifyPasswordResetCodeFailureFirebase
|
||||
extends VerifyPasswordResetCodeFailureInterface {
|
||||
VerifyPasswordResetCodeFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
VerifyPasswordResetCodeFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
|
||||
VerifyPasswordResetCodeFailureFirebase.fromCode(super.code)
|
||||
: super.fromCode();
|
||||
}
|
||||
|
||||
class RefreshFailureFirebase extends RefreshFailureInterface {
|
||||
RefreshFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
RefreshFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
RefreshFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
||||
class SignOutFailureFirebase extends SignOutFailureInterface {
|
||||
SignOutFailureFirebase([String? code, String? message])
|
||||
: super(code ?? 'unknown', message ?? 'An unknown error occurred.');
|
||||
SignOutFailureFirebase([String? code, String? msg])
|
||||
: super(code ?? 'unknown', msg ?? 'An unknown error occurred.');
|
||||
|
||||
SignOutFailureFirebase.fromCode(super.code) : super.fromCode();
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2022 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
export 'cryptography.dart';
|
@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2022 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
export 'data_sources/data_sources.dart';
|
||||
export 'entities/entities.dart';
|
||||
export 'repositories/repositories.dart';
|
@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2022 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
|
||||
abstract class Account extends Entity {
|
||||
/// The user's unique ID.
|
||||
String get uid;
|
||||
|
||||
/// The users email address.
|
||||
///
|
||||
/// Will be `null` if signing in anonymously.
|
||||
String? get email;
|
||||
}
|
@ -14,9 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:wyatt_authentication_bloc/src/data/models/user_firebase.dart';
|
||||
import 'package:wyatt_architecture/wyatt_architecture.dart';
|
||||
import 'package:wyatt_authentication_bloc/src/domain/entities/account.dart';
|
||||
|
||||
extension FirebaseAuthUserX on User {
|
||||
UserFirebase get model => UserFirebase(this);
|
||||
abstract class AccountWrapper<T> extends Entity {
|
||||
Account? get account;
|
||||
T? get data;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2022 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
export 'account.dart';
|
||||
export 'account_wrapper.dart';
|
@ -1,85 +0,0 @@
|
||||
// Copyright (C) 2022 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
abstract class User {
|
||||
/// The empty user constructor.
|
||||
const User.empty();
|
||||
|
||||
/// The users display name.
|
||||
///
|
||||
/// Will be `null` if signing in anonymously or via password authentication.
|
||||
String? get displayName;
|
||||
|
||||
/// The users email address.
|
||||
///
|
||||
/// Will be `null` if signing in anonymously.
|
||||
String? get email;
|
||||
|
||||
/// Returns whether the users email address has been verified.
|
||||
///
|
||||
/// To send a verification email, see `SendEmailVerification`.
|
||||
///
|
||||
/// Once verified, call `reload` to ensure the latest user information is
|
||||
/// retrieved from Firebase.
|
||||
bool get emailVerified;
|
||||
|
||||
/// Returns whether the user is a anonymous.
|
||||
bool get isAnonymous;
|
||||
|
||||
/// Returns the users account creation time.
|
||||
///
|
||||
/// When this account was created as dictated by the server clock.
|
||||
DateTime? get creationTime;
|
||||
|
||||
/// When the user last signed in as dictated by the server clock.
|
||||
///
|
||||
/// This is only accurate up to a granularity of 2 minutes for consecutive
|
||||
/// sign-in attempts.
|
||||
DateTime? get lastSignInTime;
|
||||
|
||||
/// Returns the users phone number.
|
||||
///
|
||||
/// This property will be `null` if the user has not signed in or been has
|
||||
/// their phone number linked.
|
||||
String? get phoneNumber;
|
||||
|
||||
/// Returns a photo URL for the user.
|
||||
///
|
||||
/// This property will be populated if the user has signed in or been linked
|
||||
/// with a 3rd party OAuth provider (such as Google).
|
||||
String? get photoURL;
|
||||
|
||||
/// Returns a JWT refresh token for the user.
|
||||
///
|
||||
/// This property maybe `null` or empty if the underlying platform does not
|
||||
/// support providing refresh tokens.
|
||||
String? get refreshToken;
|
||||
|
||||
/// The user's unique ID.
|
||||
String get uid;
|
||||
|
||||
/// The provider ID for the user.
|
||||
String? get providerId;
|
||||
|
||||
/// Whether the user account has been recently created.
|
||||
bool? get isNewUser;
|
||||
|
||||
/// Convenience getter to determine whether the current user is empty.
|
||||
bool get isEmpty;
|
||||
|
||||
/// Convenience getter to determine whether the current user is not empty.
|
||||
bool get isNotEmpty;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user