mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-13 08:25:29 -04:00
password work
This commit is contained in:
parent
9d1eaeed4c
commit
960b8375b5
14 changed files with 77 additions and 182 deletions
|
@ -10,12 +10,12 @@ import '../tools/tools.dart';
|
|||
|
||||
class EnterPinDialog extends ConsumerStatefulWidget {
|
||||
const EnterPinDialog({
|
||||
this.matchPin,
|
||||
this.description,
|
||||
required this.reenter,
|
||||
required this.description,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String? matchPin;
|
||||
final bool reenter;
|
||||
final String? description;
|
||||
|
||||
@override
|
||||
|
@ -25,8 +25,8 @@ class EnterPinDialog extends ConsumerStatefulWidget {
|
|||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties
|
||||
..add(StringProperty('matchPin', matchPin))
|
||||
..add(StringProperty('description', description));
|
||||
..add(StringProperty('description', description))
|
||||
..add(DiagnosticsProperty<bool>('reenter', reenter));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class EnterPinDialogState extends ConsumerState<EnterPinDialog> {
|
|||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
widget.matchPin == null
|
||||
!widget.reenter
|
||||
? translate('enter_pin_dialog.enter_pin')
|
||||
: translate('enter_pin_dialog.reenter_pin'),
|
||||
style: theme.textTheme.titleLarge,
|
||||
|
@ -94,23 +94,10 @@ class EnterPinDialogState extends ConsumerState<EnterPinDialog> {
|
|||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
],
|
||||
// validator: (widget.matchPin != null)
|
||||
// ? (value) => value == widget.matchPin
|
||||
// ? null
|
||||
// : translate('enter_pin_dialog.pin_does_not_match')
|
||||
// : null,
|
||||
// onClipboardFound: (value) {
|
||||
// debugPrint('onClipboardFound: $value');
|
||||
// pinController.setText(value);
|
||||
// },
|
||||
hapticFeedbackType: HapticFeedbackType.lightImpact,
|
||||
onCompleted: (pin) {
|
||||
debugPrint('onCompleted: $pin');
|
||||
Navigator.pop(context, pin);
|
||||
},
|
||||
onChanged: (value) {
|
||||
debugPrint('onChanged: $value');
|
||||
},
|
||||
cursor: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
|
@ -129,13 +116,6 @@ class EnterPinDialogState extends ConsumerState<EnterPinDialog> {
|
|||
border: Border.all(color: borderColor),
|
||||
),
|
||||
),
|
||||
errorText: '',
|
||||
errorPinTheme: defaultPinTheme.copyWith(
|
||||
decoration: BoxDecoration(
|
||||
color: scale.errorScale.border,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
).paddingAll(16),
|
||||
),
|
||||
if (widget.description != null)
|
||||
|
|
|
@ -11,6 +11,7 @@ import '../providers/contact.dart';
|
|||
import '../providers/contact_invite.dart';
|
||||
import '../tools/tools.dart';
|
||||
import '../veilid_support/veilid_support.dart';
|
||||
import 'enter_password.dart';
|
||||
import 'enter_pin.dart';
|
||||
import 'profile_widget.dart';
|
||||
|
||||
|
@ -184,22 +185,22 @@ class PasteInviteDialogState extends ConsumerState<PasteInviteDialog> {
|
|||
}
|
||||
final pin = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
EnterPinDialog(description: description));
|
||||
builder: (context) => EnterPinDialog(
|
||||
reenter: false, description: description));
|
||||
if (pin == null) {
|
||||
return null;
|
||||
}
|
||||
encryptionKey = pin;
|
||||
case EncryptionKeyType.password:
|
||||
final description =
|
||||
translate('contact_invite.protected_with_pin');
|
||||
translate('contact_invite.protected_with_password');
|
||||
if (!context.mounted) {
|
||||
return null;
|
||||
}
|
||||
final password = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
EnterPinDialog(description: description));
|
||||
EnterPasswordDialog(description: description));
|
||||
if (password == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -215,6 +216,7 @@ class PasteInviteDialogState extends ConsumerState<PasteInviteDialog> {
|
|||
// Check if validation was cancelled
|
||||
if (validatedContactInvitation == null) {
|
||||
setState(() {
|
||||
_pasteTextController.text = '';
|
||||
_validatingPaste = false;
|
||||
_validInvitation = null;
|
||||
});
|
||||
|
@ -233,20 +235,22 @@ class PasteInviteDialogState extends ConsumerState<PasteInviteDialog> {
|
|||
switch (e.type) {
|
||||
case EncryptionKeyType.none:
|
||||
errorText = translate('contact_invite.invalid_invitation');
|
||||
case EncryptionKeyType.password:
|
||||
errorText = translate('contact_invite.invalid_pin');
|
||||
case EncryptionKeyType.pin:
|
||||
errorText = translate('contact_invite.invalid_pin');
|
||||
case EncryptionKeyType.password:
|
||||
errorText = translate('contact_invite.invalid_password');
|
||||
}
|
||||
if (context.mounted) {
|
||||
showErrorToast(context, errorText);
|
||||
}
|
||||
setState(() {
|
||||
_pasteTextController.text = '';
|
||||
_validatingPaste = false;
|
||||
_validInvitation = null;
|
||||
});
|
||||
} on Exception catch (_) {
|
||||
setState(() {
|
||||
_pasteTextController.text = '';
|
||||
_validatingPaste = false;
|
||||
_validInvitation = null;
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ import '../providers/contact_invite.dart';
|
|||
import '../tools/tools.dart';
|
||||
import '../veilid_support/veilid_support.dart';
|
||||
import 'contact_invitation_display.dart';
|
||||
import 'enter_password.dart';
|
||||
import 'enter_pin.dart';
|
||||
|
||||
class SendInviteDialog extends ConsumerStatefulWidget {
|
||||
|
@ -55,7 +56,8 @@ class SendInviteDialogState extends ConsumerState<SendInviteDialog> {
|
|||
final description = translate('send_invite_dialog.pin_description');
|
||||
final pin = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => EnterPinDialog(description: description));
|
||||
builder: (context) =>
|
||||
EnterPinDialog(reenter: false, description: description));
|
||||
if (pin == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -66,7 +68,7 @@ class SendInviteDialogState extends ConsumerState<SendInviteDialog> {
|
|||
final matchpin = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => EnterPinDialog(
|
||||
matchPin: pin,
|
||||
reenter: true,
|
||||
description: description,
|
||||
));
|
||||
if (matchpin == null) {
|
||||
|
@ -91,11 +93,42 @@ class SendInviteDialogState extends ConsumerState<SendInviteDialog> {
|
|||
}
|
||||
|
||||
Future<void> _onPasswordEncryptionSelected(bool selected) async {
|
||||
setState(() {
|
||||
if (selected) {
|
||||
final description = translate('send_invite_dialog.password_description');
|
||||
final password = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => EnterPasswordDialog(description: description));
|
||||
if (password == null) {
|
||||
return;
|
||||
}
|
||||
// ignore: use_build_context_synchronously
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
final matchpass = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => EnterPasswordDialog(
|
||||
matchPass: password,
|
||||
description: description,
|
||||
));
|
||||
if (matchpass == null) {
|
||||
return;
|
||||
} else if (password == matchpass) {
|
||||
setState(() {
|
||||
_encryptionKeyType = EncryptionKeyType.password;
|
||||
_encryptionKey = password;
|
||||
});
|
||||
} else {
|
||||
// ignore: use_build_context_synchronously
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
showErrorToast(
|
||||
context, translate('send_invite_dialog.password_does_not_match'));
|
||||
setState(() {
|
||||
_encryptionKeyType = EncryptionKeyType.none;
|
||||
_encryptionKey = '';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onGenerateButtonPressed() async {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue