Skip to content
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

Improve password validation handling #152

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/screens/authentification/create_password_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class _CreatePasswordPageState extends State<CreatePasswordPage> {
if (text.isEmpty ||
text2.isEmpty ||
!_formKey.currentState.validate() ||
controller1.text != controller2.text) {
controller1.text != controller2.text ||
controller1.text.length < 12 ||
controller2.text.length < 12) {
setState(() {
isValidPassword = false;
});
Expand All @@ -49,12 +51,16 @@ class _CreatePasswordPageState extends State<CreatePasswordPage> {
}

bool _validateInputs() {
// Only validate if the user has entered atleast 3 characters.
if (controller1.text.length < 3) {
return false;
}
if (_formKey.currentState.validate()) {
// If all data are correct then save data to out variables
// If all data are correct then save data to out variables
_formKey.currentState.save();
return true;
} else {
// If all data are not valid then start auto validation.
// If all data are not valid then start auto validation.
setState(() {
_autoValidate = true;
});
Expand Down Expand Up @@ -90,6 +96,9 @@ class _CreatePasswordPageState extends State<CreatePasswordPage> {
_fieldFocusChange(context, _focus1, _focus2);
_validateInputs();
},
onChanged: (value) {
_validateInputs();
},
textInputAction: TextInputAction.next,
autocorrect: false,
enableInteractiveSelection: true,
Expand Down