-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add HydratedAuthCubitBase abstract class
- this will alow creating AuthCubit based on different backends or repositories.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
packages/djangoflow_auth/djangoflow_auth/lib/src/blocs/auth_cubit/auth_cubit_base.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'package:djangoflow_auth/djangoflow_auth.dart'; | ||
import 'package:djangoflow_openapi/djangoflow_openapi.dart'; | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
|
||
/// This is the base class for AuthCubit. | ||
/// It allows to create AuthCubit based on any kind of backends. | ||
abstract class HydratedAuthCubitBase extends HydratedCubit<AuthState> { | ||
HydratedAuthCubitBase(AuthState initialState) : super(initialState); | ||
|
||
List<SocialLogin> socialLogins = []; | ||
|
||
/// Authenticate and request token for user from the Social Auth Provider | ||
/// eg, facebook, google etc. | ||
Future<R?> requestTokenFromSocialProvider<R>(SocialLoginType type); | ||
|
||
Future<void> logoutFromSocialProvider(SocialLoginType type); | ||
|
||
Future<void> logout(); | ||
|
||
Future<UserIdentity?> registerOrInviteUser({ | ||
required UserIdentityRequest userIdentityRequest, | ||
}); | ||
|
||
Future<void> requestOTP({required OTPObtainRequest otpObtainRequest}); | ||
|
||
/// Authenticates the user based on provided credentials (e.g., username+password or email+OTP etc) | ||
/// and logs them in by obtaining and processing a JWT token. | ||
Future<void> obtainTokenAndLogin({ | ||
required TokenObtainRequest tokenObtainRequest, | ||
}); | ||
|
||
/// Login user with magic link. magiclink should not be empty | ||
/// It supports only email at the moment. | ||
Future<void> loginWithMagicLink({required String magiclink}); | ||
|
||
/// Login user with social provider token data that was retrieved via [requestTokenFromSocialProvider] | ||
/// This will retrieve token from backend and login user | ||
Future<void> loginWithSocialProviderToken( | ||
{required SocialTokenObtainRequest socialTokenObtainRequest}); | ||
|
||
Future<void> changePassword({ | ||
required String id, | ||
required ChangePasswordRequest changePasswordRequest, | ||
}); | ||
} |