Skip to content

Commit

Permalink
Merge branch 'rustdesk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbo8418 authored Jan 20, 2024
2 parents 73c088f + 804f035 commit 4dea0b3
Show file tree
Hide file tree
Showing 40 changed files with 378 additions and 87 deletions.
336 changes: 284 additions & 52 deletions flutter/lib/common/widgets/dialog.dart

Large diffs are not rendered by default.

53 changes: 18 additions & 35 deletions flutter/lib/common/widgets/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -615,23 +615,11 @@ Future<bool?> verificationCodeDialog(
var autoLogin = true;
var isInProgress = false;
String? errorText;
String preCode = '';

final code = TextEditingController();
final focusNode = FocusNode()..requestFocus();
Timer(Duration(milliseconds: 100), () => focusNode..requestFocus());

final res = await gFFI.dialogManager.show<bool>((setState, close, context) {
bool validate() {
return code.text.length >= 6;
}

void onVerify() async {
if (!validate()) {
setState(
() => errorText = translate('Too short, at least 6 characters.'));
return;
}
setState(() => isInProgress = true);

try {
Expand Down Expand Up @@ -666,18 +654,21 @@ Future<bool?> verificationCodeDialog(
setState(() => isInProgress = false);
}

code.addListener(() {
if (errorText != null) {
setState(() => errorText = null);
}
if (preCode.length != 6 && code.text.length == 6) {
onVerify();
}
if (!isEmailVerification && preCode.length != 10 && code.text.length == 10) {
onVerify();
}
preCode = code.text;
});
final codeField = isEmailVerification
? DialogEmailCodeField(
controller: code,
errorText: errorText,
readyCallback: onVerify,
onChanged: () => errorText = null,
)
: Dialog2FaField(
controller: code,
errorText: errorText,
readyCallback: onVerify,
onChanged: () => errorText = null,
);

getOnSubmit() => codeField.isReady ? onVerify : null;

return CustomAlertDialog(
title: Text(translate("Verification code")),
Expand All @@ -693,15 +684,7 @@ Future<bool?> verificationCodeDialog(
controller: TextEditingController(text: user?.email),
)),
isEmailVerification ? const SizedBox(height: 8) : const Offstage(),
DialogTextField(
title:
'${translate(isEmailVerification ? "Verification code" : "2FA code")}:',
controller: code,
errorText: errorText,
focusNode: focusNode,
helperText: translate(
isEmailVerification ? 'verification_tip' : '2fa_tip'),
),
codeField,
/*
CheckboxListTile(
contentPadding: const EdgeInsets.all(0),
Expand All @@ -722,10 +705,10 @@ Future<bool?> verificationCodeDialog(
],
),
onCancel: close,
onSubmit: onVerify,
onSubmit: getOnSubmit(),
actions: [
dialogButton("Cancel", onPressed: close, isOutline: true),
dialogButton("Verify", onPressed: onVerify),
dialogButton("Verify", onPressed: getOnSubmit()),
]);
});

Expand Down
2 changes: 2 additions & 0 deletions src/lang/ar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/ca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/cn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", "Email 验证码必须是 6 个字符。"),
("2FA code must be 6 digits.", "2FA 码必须是6位数字。"),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", "Bitte richten Sie jetzt Ihren Authentifikator ein. Sie können eine Authentifizierungs-App wie Authy, Microsoft oder Google Authenticator auf Ihrem Telefon oder Desktop verwenden.\n\nScannen Sie den QR-Code mit Ihrer App und geben Sie den Code ein, den Ihre App anzeigt, um die Zwei-Faktor-Authentifizierung zu aktivieren."),
("wrong-2fa-code", "Der Code kann nicht verifiziert werden. Prüfen Sie, ob der Code und die lokalen Zeiteinstellungen korrekt sind."),
("enter-2fa-title", "Zwei-Faktor-Authentifizierung"),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/el.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/eo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/es.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/et.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/fa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/fr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/hu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/it.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/ja.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/ko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/kz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/lt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/lv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/nb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/nl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/pl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/pt_PT.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/ptbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/ro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/ru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/sk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/sl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/sq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/sr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/sv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/th.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/tw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/ua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}
2 changes: 2 additions & 0 deletions src/lang/vn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("enable-2fa-desc", ""),
("wrong-2fa-code", ""),
("enter-2fa-title", ""),
("Email verification code must be 6 characters.", ""),
("2FA code must be 6 digits.", ""),
].iter().cloned().collect();
}

0 comments on commit 4dea0b3

Please sign in to comment.