mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 07:48:40 +00:00
fix proof of work issue
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run
This commit is contained in:
parent
b9bb074ba6
commit
e17e39ef41
8 changed files with 38 additions and 6 deletions
|
|
@ -20,6 +20,7 @@
|
|||
"registerUsernameSlogan": "Bitte wähle einen Benutzernamen, damit dich andere finden können!",
|
||||
"registerUsernameDecoration": "Benutzername",
|
||||
"registerUsernameLimits": "Der Benutzername muss mindestens 3 Zeichen lang sein.",
|
||||
"registerProofOfWorkFailed": "Beim Captcha-Test gab es ein Problem. Bitte versuche es erneut.",
|
||||
"registerSubmitButton": "Jetzt registrieren!",
|
||||
"registerTwonlyCodeText": "Hast du einen twonly-Code erhalten? Dann löse ihn entweder direkt hier oder später ein!",
|
||||
"registerTwonlyCodeLabel": "twonly-Code",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
"registerUsernameSlogan": "Please select a username so others can find you!",
|
||||
"registerUsernameDecoration": "Username",
|
||||
"registerUsernameLimits": "Your username must be at least 3 characters long.",
|
||||
"registerProofOfWorkFailed": "There was an issue with the captcha test. Please try again.",
|
||||
"registerSubmitButton": "Register now!",
|
||||
"registerTwonlyCodeText": "Have you received a twonly code? Then redeem it either directly here or later!",
|
||||
"registerTwonlyCodeLabel": "twonly-Code",
|
||||
|
|
|
|||
|
|
@ -218,6 +218,12 @@ abstract class AppLocalizations {
|
|||
/// **'Your username must be at least 3 characters long.'**
|
||||
String get registerUsernameLimits;
|
||||
|
||||
/// No description provided for @registerProofOfWorkFailed.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'There was an issue with the captcha test. Please try again.'**
|
||||
String get registerProofOfWorkFailed;
|
||||
|
||||
/// No description provided for @registerSubmitButton.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||
String get registerUsernameLimits =>
|
||||
'Der Benutzername muss mindestens 3 Zeichen lang sein.';
|
||||
|
||||
@override
|
||||
String get registerProofOfWorkFailed =>
|
||||
'Beim Captcha-Test gab es ein Problem. Bitte versuche es erneut.';
|
||||
|
||||
@override
|
||||
String get registerSubmitButton => 'Jetzt registrieren!';
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||
String get registerUsernameLimits =>
|
||||
'Your username must be at least 3 characters long.';
|
||||
|
||||
@override
|
||||
String get registerProofOfWorkFailed =>
|
||||
'There was an issue with the captcha test. Please try again.';
|
||||
|
||||
@override
|
||||
String get registerSubmitButton => 'Register now!';
|
||||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class _SearchUsernameView extends State<AddNewUserView> {
|
|||
},
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(12),
|
||||
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z]')),
|
||||
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z._]')),
|
||||
],
|
||||
controller: searchUserName,
|
||||
decoration:
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class _RegisterViewState extends State<RegisterView> {
|
|||
bool _isTryingToRegister = false;
|
||||
bool _isValidUserName = false;
|
||||
bool _showUserNameError = false;
|
||||
bool _showProofOfWorkError = false;
|
||||
|
||||
late Future<int>? proofOfWork;
|
||||
|
||||
|
|
@ -63,6 +64,7 @@ class _RegisterViewState extends State<RegisterView> {
|
|||
setState(() {
|
||||
_isTryingToRegister = true;
|
||||
_showUserNameError = false;
|
||||
_showProofOfWorkError = false;
|
||||
});
|
||||
|
||||
late int proof;
|
||||
|
|
@ -93,6 +95,7 @@ class _RegisterViewState extends State<RegisterView> {
|
|||
Log.info('Got user_id ${res.value} from server');
|
||||
userId = res.value.userid.toInt() as int;
|
||||
} else {
|
||||
proofOfWork = null;
|
||||
if (res.error == ErrorCode.RegistrationDisabled) {
|
||||
_registrationDisabled = true;
|
||||
return;
|
||||
|
|
@ -103,9 +106,12 @@ class _RegisterViewState extends State<RegisterView> {
|
|||
return createNewUser();
|
||||
}
|
||||
if (res.error == ErrorCode.InvalidProofOfWork) {
|
||||
Log.error('Proof of Work is invalid. Try again.');
|
||||
await deleteLocalUserData();
|
||||
return createNewUser();
|
||||
setState(() {
|
||||
_showProofOfWorkError = true;
|
||||
_isTryingToRegister = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
|
@ -232,7 +238,7 @@ class _RegisterViewState extends State<RegisterView> {
|
|||
},
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(12),
|
||||
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z]')),
|
||||
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z._]')),
|
||||
],
|
||||
style: const TextStyle(fontSize: 17),
|
||||
decoration: getInputDecoration(
|
||||
|
|
@ -248,7 +254,17 @@ class _RegisterViewState extends State<RegisterView> {
|
|||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
context.lang.registerProofOfWorkFailed,
|
||||
style: TextStyle(
|
||||
color:
|
||||
_showProofOfWorkError ? Colors.red : Colors.transparent,
|
||||
fontSize: 12,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Column(
|
||||
children: [
|
||||
FilledButton.icon(
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class _ProfileViewState extends State<ProfileView> {
|
|||
maxLength: 12,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(12),
|
||||
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z]')),
|
||||
FilteringTextInputFormatter.allow(RegExp('[a-z0-9A-Z._]')),
|
||||
],
|
||||
);
|
||||
if (context.mounted && username != null && username != '') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue