|
@@ -18,6 +18,7 @@ class ChangePasswordForm extends HookConsumerWidget {
|
|
|
final confirmPasswordController =
|
|
|
useTextEditingController.fromValue(TextEditingValue.empty);
|
|
|
final authState = ref.watch(authenticationProvider);
|
|
|
+ final formKey = GlobalKey<FormState>();
|
|
|
|
|
|
return Center(
|
|
|
child: ConstrainedBox(
|
|
@@ -47,15 +48,24 @@ class ChangePasswordForm extends HookConsumerWidget {
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
- PasswordInput(controller: passwordController),
|
|
|
- ConfirmPasswordInput(
|
|
|
- originalController: passwordController,
|
|
|
- confirmController: confirmPasswordController,
|
|
|
- ),
|
|
|
- Align(
|
|
|
- alignment: Alignment.center,
|
|
|
- child: ChangePasswordButton(
|
|
|
- passwordController: passwordController),
|
|
|
+ Form(
|
|
|
+ key: formKey,
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ PasswordInput(controller: passwordController),
|
|
|
+ Padding(
|
|
|
+ padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
|
+ child: ConfirmPasswordInput(
|
|
|
+ originalController: passwordController,
|
|
|
+ confirmController: confirmPasswordController,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ChangePasswordButton(
|
|
|
+ passwordController: passwordController,
|
|
|
+ formKey: formKey,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
)
|
|
|
],
|
|
|
),
|
|
@@ -119,10 +129,12 @@ class ConfirmPasswordInput extends StatelessWidget {
|
|
|
|
|
|
class ChangePasswordButton extends ConsumerWidget {
|
|
|
final TextEditingController passwordController;
|
|
|
+ final GlobalKey<FormState> formKey;
|
|
|
|
|
|
const ChangePasswordButton({
|
|
|
Key? key,
|
|
|
required this.passwordController,
|
|
|
+ required this.formKey,
|
|
|
}) : super(key: key);
|
|
|
|
|
|
@override
|
|
@@ -136,19 +148,21 @@ class ChangePasswordButton extends ConsumerWidget {
|
|
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 25),
|
|
|
),
|
|
|
onPressed: () async {
|
|
|
- var isSuccess = await ref
|
|
|
- .watch(authenticationProvider.notifier)
|
|
|
- .changePassword(passwordController.value.text);
|
|
|
+ if (formKey.currentState!.validate()) {
|
|
|
+ var isSuccess = await ref
|
|
|
+ .watch(authenticationProvider.notifier)
|
|
|
+ .changePassword(passwordController.value.text);
|
|
|
|
|
|
- if (isSuccess) {
|
|
|
- bool res =
|
|
|
- await ref.watch(authenticationProvider.notifier).logout();
|
|
|
+ if (isSuccess) {
|
|
|
+ bool res =
|
|
|
+ await ref.watch(authenticationProvider.notifier).logout();
|
|
|
|
|
|
- if (res) {
|
|
|
- ref.watch(backupProvider.notifier).cancelBackup();
|
|
|
- ref.watch(assetProvider.notifier).clearAllAsset();
|
|
|
- ref.watch(websocketProvider.notifier).disconnect();
|
|
|
- AutoRouter.of(context).replace(const LoginRoute());
|
|
|
+ if (res) {
|
|
|
+ ref.watch(backupProvider.notifier).cancelBackup();
|
|
|
+ ref.watch(assetProvider.notifier).clearAllAsset();
|
|
|
+ ref.watch(websocketProvider.notifier).disconnect();
|
|
|
+ AutoRouter.of(context).replace(const LoginRoute());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|