-
Notifications
You must be signed in to change notification settings - Fork 0
feat(auth): add sign-up flow and reusable auth form widgets #14
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
15 commits
Select commit
Hold shift + click to select a range
0e2d229
refactor(auth): make the emailVerifiedAt field nullable to comply witβ¦
CowboyGH 33b44ba
feat(auth): add register DTOs and API client endpoint
CowboyGH 6052b2d
feat(auth): add signUp method to auth repository
CowboyGH cab48a6
test(auth): add unit tests for AuthRepositoryImpl.signUp
CowboyGH 1f912ed
feat(auth): implement SignUpCubit
CowboyGH d195dee
test(auth): add unit tests for SignUpCubit
CowboyGH a98ffec
feat(auth): add sign-up page and router wiring
CowboyGH 7c499fa
refactor(auth): extract shared AuthFlowShell
CowboyGH 48f7fb6
refactor(auth): extract shared AuthTextField and AuthPasswordField
CowboyGH 01a80f9
refactor(auth): extract shared AuthSwitchSection
CowboyGH e02f1fd
refactor(auth): extract local ConsentRow widget
CowboyGH 7ee256b
refactor(auth): change checkbox validation message
CowboyGH 32b6382
docs: update CHANGELOG.md
CowboyGH 4482a39
refactor(auth): make skip section available in release
CowboyGH 7fe413a
refactor(auth): extract shared auth form widgets and centralize form β¦
CowboyGH 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
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import 'package:json_annotation/json_annotation.dart'; | ||
|
|
||
| part 'register_request_dto.g.dart'; | ||
|
|
||
| /// DTO for the register request. | ||
| @JsonSerializable(createFactory: false) | ||
| class RegisterRequestDto { | ||
| /// User name. | ||
| final String name; | ||
|
|
||
| /// User email. | ||
| final String email; | ||
|
|
||
| /// User password. | ||
| final String password; | ||
|
|
||
| /// Creates an instance of [RegisterRequestDto]. | ||
| RegisterRequestDto({ | ||
| required this.name, | ||
| required this.email, | ||
| required this.password, | ||
| }); | ||
|
|
||
| /// Converts [RegisterRequestDto] to JSON. | ||
| Map<String, dynamic> toJson() => _$RegisterRequestDtoToJson(this); | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import 'package:json_annotation/json_annotation.dart'; | ||
|
|
||
| import 'user_dto.dart'; | ||
|
|
||
| part 'register_response_dto.g.dart'; | ||
|
|
||
| /// DTO for the register response. | ||
| @JsonSerializable(createToJson: false) | ||
| class RegisterResponseDto { | ||
| /// Indicates whether the register request succeeded. | ||
| final bool success; | ||
|
|
||
| /// Backend message about registration result. | ||
| final String message; | ||
|
|
||
| /// Registered user. | ||
| final UserDto user; | ||
|
|
||
| /// Creates an instance of [RegisterResponseDto]. | ||
| RegisterResponseDto({ | ||
| required this.success, | ||
| required this.message, | ||
| required this.user, | ||
| }); | ||
|
|
||
| /// Creates a [RegisterResponseDto] from JSON. | ||
| factory RegisterResponseDto.fromJson(Map<String, dynamic> json) => | ||
| _$RegisterResponseDtoFromJson(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
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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import 'package:flutter_bloc/flutter_bloc.dart'; | ||
| import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
|
||
| import '../../../../core/failures/feature/auth/auth_failure.dart'; | ||
| import '../../../../core/result/result.dart'; | ||
| import '../../domain/entities/user.dart'; | ||
| import '../../domain/repositories/auth_repository.dart'; | ||
|
|
||
| part 'sign_up_cubit.freezed.dart'; | ||
| part 'sign_up_state.dart'; | ||
|
|
||
| /// Cubit that manages sign-up flow and emits [SignUpState]. | ||
| final class SignUpCubit extends Cubit<SignUpState> { | ||
| /// Authentication repository used for sign-up requests. | ||
| final AuthRepository _repository; | ||
|
|
||
| /// Creates an instance of [SignUpCubit]. | ||
| SignUpCubit(this._repository) : super(const SignUpState.initial()); | ||
|
|
||
| /// Attempts to sign up with [name], [email] and [password]. | ||
| Future<void> signUp(String name, String email, String password) async { | ||
| if (state is _InProgress) return; | ||
|
|
||
| emit(const SignUpState.inProgress()); | ||
|
|
||
| final result = await _repository.signUp(name, email, password); | ||
| if (isClosed) return; | ||
|
|
||
| switch (result) { | ||
| case Success(data: final user): | ||
| emit(SignUpState.succeed(user)); | ||
| case Failure(:final error): | ||
| emit(SignUpState.failed(error)); | ||
| } | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| part of 'sign_up_cubit.dart'; | ||
|
|
||
| /// States for [SignUpCubit]. | ||
| @freezed | ||
| class SignUpState with _$SignUpState { | ||
| /// Initial idle state before any register attempt. | ||
| const factory SignUpState.initial() = _Initial; | ||
|
|
||
| /// State emitted when sign-up succeeds. | ||
| const factory SignUpState.succeed(User user) = _Succeed; | ||
|
|
||
| /// State emitted when sign-up fails. | ||
| const factory SignUpState.failed(AuthFailure failure) = _Failed; | ||
|
|
||
| /// State emitted while sign-up request is in progress. | ||
| const factory SignUpState.inProgress() = _InProgress; | ||
| } |
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.