8000 Fix password hint by Withalion · Pull Request #3798 · MerginMaps/mobile · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix password hint #3798

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

Merged
merged 5 commits into from
Apr 29, 2025
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
56 changes: 43 additions & 13 deletions core/merginapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,13 @@ void MerginApi::registerUser( const QString &email,

if ( password.isEmpty() || password.length() < 8 )
{
QString msg = tr( "Password not strong enough. It must"
"%1 be at least 8 characters long"
"%1 contain lowercase characters"
"%1 contain uppercase characters"
"%1 contain digits or special characters" )
.arg( "<br /> -" );
const QString msg = tr( "%1%3 Password must be at least 8 characters long and include:"
"<ul type=\"disc\">"
"%3 Lowercase characters (a-z)%4"
"%3 Uppercase characters (A-Z)%4"
"%3 At least one digit (0–9) or special character%4"
"%2%4%2" )
.arg( "<ul>", "</ul>", "<li>", "</li>" );
emit registrationFailed( msg, RegistrationError::RegistrationErrorType::PASSWORD );
return;

Expand Down Expand Up @@ -1293,25 +1294,54 @@ void MerginApi::registrationFinished( const QString &login, const QString &passw
}
else
{
QString serverMsg = extractServerErrorMsg( r->readAll() );
const QByteArray data = r->readAll();
const QString serverErrorCode = extractServerErrorCode( data );
QString serverMsg = extractServerErrorMsg( data );
CoreUtils::log( "register", QStringLiteral( "FAILED - %1. %2" ).arg( r->errorString(), serverMsg ) );
QVariant statusCode = r->attribute( QNetworkRequest::HttpStatusCodeAttribute );
int status = statusCode.toInt();
const QVariant statusCode = r->attribute( QNetworkRequest::HttpStatusCodeAttribute );
const int status = statusCode.toInt();
if ( status == 401 || status == 400 )
{
emit registrationFailed( serverMsg, RegistrationError::RegistrationErrorType::OTHER );
emit notifyError( serverMsg );
if ( serverErrorCode == "InvalidUsername" || serverErrorCode == "InvalidEmail" )
{
const QString msg = tr( "Please enter a valid email" );
emit registrationFailed( msg, RegistrationError::RegistrationErrorType::EMAIL );
emit notifyError( tr( "Registration failed" ) );
}
else if ( serverErrorCode == "ExistingEmail" )
{
const QString msg = tr( "This email address is already registered" );
emit registrationFailed( msg, RegistrationError::RegistrationErrorType::EMAIL );
emit notifyError( tr( "Registration failed" ) );
}
else if ( serverErrorCode == "InvalidPassword" )
{
const QString msg = tr( "%1%3 Password must be at least 8 characters long and include:"
"<ul type=\"disc\">"
"%3 Lowercase characters (a-z)%4"
"%3 Uppercase characters (A-Z)%4"
"%3 At least one digit (0–9) or special character%4"
"%2%4%2" )
.arg( "<ul>", "</ul>", "<li>", "</li>" );
emit registrationFailed( msg, RegistrationError::RegistrationErrorType::PASSWORD );
emit notifyError( tr( "Registration failed" ) );
}
else
{
emit registrationFailed( serverMsg, RegistrationError::RegistrationErrorType::OTHER );
emit notifyError( serverMsg );
}
}
else if ( status == 404 )
{
// the self-registration is not allowed on the server
QString msg = tr( "New registrations are not allowed on the selected server. Please check with your administrator." );
const QString msg = tr( "New registrations are not allowed on the selected server. Please check with your administrator." );
emit registrationFailed( msg, RegistrationError::RegistrationErrorType::OTHER );
emit notifyError( msg );
}
else
{
QString msg = QStringLiteral( "Mergin API error: register" );
const QString msg = QStringLiteral( "Mergin API error: register" );
emit registrationFailed( msg, RegistrationError::RegistrationErrorType::OTHER );
emit networkErrorOccurred( serverMsg, msg );
}
Expand Down
Loading
0