-
Notifications
You must be signed in to change notification settings - Fork 7
feat: Implemented forgot password and verify OTP functionality #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d29db54
feat: Implemented forgot password and verify OTP functionality
tulsi-7span 6ed300f
Fix: Moved pinput dependency from dev_dependencies to dependencies
tulsi-7span 3435374
Add const keyword for ResendEmailEvent in VerifyOTPBloc
tulsi-7span e4ce88e
- Added `did_not_receive_otp` key to `en.i18n.json`.
tulsi-7span 7a86f52
Refactor: Improve OTP verification and UI elements
tulsi-7span 9b690e4
Fix: Added mounted checks in VerifyOTPScreen timer callbacks
tulsi-7span 6e7ed9b
Update COUNTER
tulsi-7span 4d53226
Merge remote-tracking branch 'origin/main' into feat/forget-pwd
tulsi-7span 1bc9240
Updated app_textfield.dart
tulsi-7span a5934fa
Feat: Add AppTimer widget and integrate with OTP verification
tulsi-7span d3750e0
Refactor: Streamline AppTimer and Verify OTP UI
tulsi-7span 878f64b
Fix: Prevent `AppTimer` from starting if initial seconds is 0
tulsi-7span d3595cb
Fix: AppTimer displays minutes and seconds
tulsi-7span cd4c593
Refactor: Improve OTP verification and UI
tulsi-7span 84584fd
Refactor: Update OTP verification and forgot password functionality
tulsi-7span 2843236
Refactor: Standardize email property in SetEmailEvent
tulsi-7span 76986cc
Refactor: Update VerifyOTPScreen and related BLoC
tulsi-7span c20d64a
Refactor: Removed unused `EmailValidator` import
tulsi-7span d01a50e
Remove unused initState from VerifyOTPScreen
tulsi-7span f84714a
Fix: Adjusted button padding on Verify OTP screen
tulsi-7span f8dc4c3
Refactor: Removed unnecessary Padding from VerifyOTPScreen
tulsi-7span c36ea3c
Refactor: Introduce AppOtpInput widget and update dependencies
tulsi-7span File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| # Increment this counter to push your code again | ||
| 1 | ||
| 2 |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -19,9 +19,11 @@ abstract interface class IAuthRepository { | |
|
|
||
| TaskEither<Failure, bool> logout(); | ||
|
|
||
| TaskEither<Failure, Unit> socialLogin({ | ||
| required AuthRequestModel requestModel, | ||
| }); | ||
| TaskEither<Failure, Unit> forgotPassword(AuthRequestModel authRequestModel); | ||
|
|
||
| TaskEither<Failure, Unit> socialLogin({required AuthRequestModel requestModel}); | ||
|
|
||
| TaskEither<Failure, AuthResponseModel> verifyOTP(AuthRequestModel authRequestModel); | ||
| } | ||
|
|
||
| // ignore: comment_references | ||
|
|
@@ -31,48 +33,28 @@ class AuthRepository implements IAuthRepository { | |
| const AuthRepository(); | ||
|
|
||
| @override | ||
| TaskEither<Failure, Unit> login( | ||
| AuthRequestModel authRequestModel, | ||
| ) => makeLoginRequest(authRequestModel) | ||
| TaskEither<Failure, Unit> login(AuthRequestModel authRequestModel) => makeLoginRequest(authRequestModel) | ||
| .chainEither(RepositoryUtils.checkStatusCode) | ||
| .chainEither( | ||
| (response) => RepositoryUtils.mapToModel(() { | ||
| return AuthResponseModel.fromMap( | ||
| response.data as Map<String, dynamic>, | ||
| ); | ||
| return AuthResponseModel.fromMap(response.data as Map<String, dynamic>); | ||
| }), | ||
| ) | ||
| .flatMap(saveUserToLocal); | ||
|
|
||
| TaskEither<Failure, Response> makeLoginRequest( | ||
| AuthRequestModel authRequestModel, | ||
| ) => userApiClient.request( | ||
| TaskEither<Failure, Response> makeLoginRequest(AuthRequestModel authRequestModel) => userApiClient.request( | ||
| requestType: RequestType.post, | ||
| path: ApiEndpoints.login, | ||
| body: authRequestModel.toMap(), | ||
| options: Options( | ||
| headers: { | ||
| 'x-api-key': 'reqres-free-v1', | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| ), | ||
| options: Options(headers: {'x-api-key': 'reqres-free-v1', 'Content-Type': 'application/json'}), | ||
| ); | ||
|
|
||
| TaskEither<Failure, Unit> saveUserToLocal( | ||
| AuthResponseModel authResponseModel, | ||
| ) => getIt<IHiveService>().setUserData( | ||
| UserModel( | ||
| name: 'user name', | ||
| email: 'user email', | ||
| profilePicUrl: '', | ||
| id: int.parse(authResponseModel.id), | ||
| ), | ||
| TaskEither<Failure, Unit> saveUserToLocal(AuthResponseModel authResponseModel) => getIt<IHiveService>().setUserData( | ||
| UserModel(name: 'user name', email: 'user email', profilePicUrl: '', id: int.parse(authResponseModel.id)), | ||
| ); | ||
|
|
||
| @override | ||
| TaskEither<Failure, Unit> signup( | ||
| AuthRequestModel authRequestModel, | ||
| ) => makeSignUpRequest(authRequestModel) | ||
| TaskEither<Failure, Unit> signup(AuthRequestModel authRequestModel) => makeSignUpRequest(authRequestModel) | ||
| .chainEither(RepositoryUtils.checkStatusCode) | ||
| .chainEither( | ||
| (r) => RepositoryUtils.mapToModel(() { | ||
|
|
@@ -82,27 +64,20 @@ class AuthRepository implements IAuthRepository { | |
| // return AuthResponseModel.fromMap( | ||
| // r.data as Map<String, dynamic>, | ||
| // ); | ||
| return AuthResponseModel( | ||
| email: '[email protected]', | ||
| id: (r.data as Map<String, dynamic>)['id'].toString(), | ||
| ); | ||
| return AuthResponseModel(email: '[email protected]', id: (r.data as Map<String, dynamic>)['id'].toString()); | ||
| }), | ||
| ) | ||
| .flatMap(saveUserToLocal); | ||
|
|
||
| TaskEither<Failure, Response> makeSignUpRequest( | ||
| AuthRequestModel authRequestModel, | ||
| ) => userApiClient.request( | ||
| TaskEither<Failure, Response> makeSignUpRequest(AuthRequestModel authRequestModel) => userApiClient.request( | ||
| requestType: RequestType.post, | ||
| path: ApiEndpoints.signup, | ||
| body: authRequestModel.toMap(), | ||
| options: Options(headers: {'Content-Type': 'application/json'}), | ||
| ); | ||
|
|
||
| TaskEither<Failure, Unit> _clearHiveData() => TaskEither.tryCatch( | ||
| () => getIt<LogoutService>().logout().run(), | ||
| (error, stackTrace) => APIFailure(), | ||
| ); | ||
| TaskEither<Failure, Unit> _clearHiveData() => | ||
| TaskEither.tryCatch(() => getIt<LogoutService>().logout().run(), (error, stackTrace) => APIFailure()); | ||
|
|
||
| @override | ||
| TaskEither<Failure, bool> logout() => makeLogoutRequest().flatMap( | ||
|
|
@@ -111,14 +86,11 @@ class AuthRepository implements IAuthRepository { | |
| }), | ||
| ); | ||
|
|
||
| TaskEither<Failure, String> _getNotificationId() => | ||
| TaskEither.tryCatch(() { | ||
| return getIt<NotificationServiceInterface>() | ||
| .getNotificationSubscriptionId(); | ||
| }, APIFailure.new); | ||
| TaskEither<Failure, String> _getNotificationId() => TaskEither.tryCatch(() { | ||
| return getIt<NotificationServiceInterface>().getNotificationSubscriptionId(); | ||
| }, APIFailure.new); | ||
|
|
||
| TaskEither<Failure, Response> | ||
| makeLogoutRequest() => _getNotificationId().flatMap( | ||
| TaskEither<Failure, Response> makeLogoutRequest() => _getNotificationId().flatMap( | ||
| (playerID) => userApiClient.request( | ||
| requestType: RequestType.delete, | ||
|
|
||
|
|
@@ -130,26 +102,54 @@ class AuthRepository implements IAuthRepository { | |
| ); | ||
|
|
||
| @override | ||
| TaskEither<Failure, Unit> socialLogin({ | ||
| required AuthRequestModel requestModel, | ||
| }) => makeSocialLoginRequest(requestModel: requestModel) | ||
| TaskEither<Failure, Unit> socialLogin({required AuthRequestModel requestModel}) => makeSocialLoginRequest( | ||
| requestModel: requestModel, | ||
| ) | ||
| .chainEither(RepositoryUtils.checkStatusCode) | ||
| .chainEither( | ||
| (response) => RepositoryUtils.mapToModel<AuthResponseModel>( | ||
| () => AuthResponseModel.fromMap( | ||
| response.data as Map<String, dynamic>, | ||
| ), | ||
| ), | ||
| (response) => | ||
| RepositoryUtils.mapToModel<AuthResponseModel>(() => AuthResponseModel.fromMap(response.data as Map<String, dynamic>)), | ||
| ) | ||
| .flatMap(saveUserToLocal); | ||
|
|
||
| TaskEither<Failure, Response> makeSocialLoginRequest({ | ||
| required AuthRequestModel requestModel, | ||
| }) { | ||
| TaskEither<Failure, Response> makeSocialLoginRequest({required AuthRequestModel requestModel}) { | ||
| return userApiClient.request( | ||
| requestType: RequestType.post, | ||
| path: ApiEndpoints.socialLogin, | ||
| body: requestModel.toSocialSignInMap(), | ||
| ); | ||
| } | ||
|
|
||
| @override | ||
| TaskEither<Failure, Unit> forgotPassword(AuthRequestModel authRequestModel) => makeForgotPasswordRequest(authRequestModel) | ||
| .chainEither(RepositoryUtils.checkStatusCode) | ||
| .chainEither( | ||
| (response) => RepositoryUtils.mapToModel(() { | ||
| return response.data; | ||
| }), | ||
| ) | ||
| .map((_) => unit); | ||
|
|
||
| TaskEither<Failure, Response> makeForgotPasswordRequest(AuthRequestModel authRequestModel) => userApiClient.request( | ||
| requestType: RequestType.post, | ||
| path: ApiEndpoints.forgotPassword, | ||
| body: authRequestModel.toForgotPasswordMap(), | ||
| options: Options(headers: {'x-api-key': 'reqres-free-v1', 'Content-Type': 'application/json'}), | ||
| ); | ||
|
|
||
| @override | ||
| TaskEither<Failure, AuthResponseModel> verifyOTP(AuthRequestModel authRequestModel) => makeVerifyOTPRequest(authRequestModel) | ||
| .chainEither(RepositoryUtils.checkStatusCode) | ||
| .chainEither( | ||
| (response) => RepositoryUtils.mapToModel(() { | ||
| return AuthResponseModel.fromMap(response.data as Map<String, dynamic>); | ||
| }), | ||
| ); | ||
|
|
||
| TaskEither<Failure, Response> makeVerifyOTPRequest(AuthRequestModel authRequestModel) => userApiClient.request( | ||
tulsi-7span marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| requestType: RequestType.post, | ||
| path: ApiEndpoints.verifyOTP, | ||
| body: authRequestModel.toVerifyOTPMap(), | ||
| options: Options(headers: {'Content-Type': 'application/json'}), | ||
| ); | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.