Commit 7079f034 authored by Andrew den Exter's avatar Andrew den Exter

Merge branch 'jb38895' into 'master'

[devicelock] Ask user to confirm a generated code twice. Fixes JB#38895

See merge request !26
parents 584d4eb8 41b48f7e
......@@ -98,6 +98,8 @@ HostAuthenticator::HostAuthenticator(Authenticator::Methods supportedMethods, QO
: HostAuthenticationInput(QStringLiteral("/authenticator"), supportedMethods, parent)
, m_adaptor(this)
, m_securityCodeAdaptor(this)
, m_repeatsRequired(0)
, m_state(Idle)
{
}
......@@ -260,13 +262,15 @@ void HostAuthenticator::enterSecurityCode(const QString &code)
qCDebug(daemon, "New security code entered.");
m_newCode = code;
m_state = RepeatingNewSecurityCode;
m_repeatsRequired = 1;
feedback(AuthenticationInput::RepeatNewSecurityCode, -1);
return;
case ExpectingGeneratedSecurityCode:
if (m_generatedCode == code) {
m_newCode = code;
m_state = RepeatingNewSecurityCode;
feedback(AuthenticationInput::RepeatNewSecurityCode, -1);
m_repeatsRequired = 2;
feedback(AuthenticationInput::EnterNewSecurityCode, -1);
} else {
feedback(AuthenticationInput::SecurityCodesDoNotMatch, QVariantMap());
feedback(AuthenticationInput::SuggestSecurityCode, generatedCodeData());
......@@ -289,14 +293,13 @@ void HostAuthenticator::enterSecurityCode(const QString &code)
m_state = AuthenticatingForChange;
feedback(AuthenticationInput::EnterSecurityCode, -1);
}
} else if (--m_repeatsRequired > 0) {
feedback(AuthenticationInput::RepeatNewSecurityCode, -1);
} else {
m_newCode.clear();
return;
setCodeFinished(setCode(m_currentCode, code));
}
m_newCode.clear();
setCodeFinished(setCode(m_currentCode, code));
return;
}
case AuthenticatingForClear: {
......
......@@ -172,6 +172,7 @@ private:
QString m_currentCode;
QString m_newCode;
QString m_generatedCode;
int m_repeatsRequired;
State m_state;
};
......
......@@ -72,6 +72,7 @@ HostDeviceLock::HostDeviceLock(Authenticator::Methods supportedMethods, QObject
: HostAuthenticationInput(QStringLiteral("/devicelock/lock"), supportedMethods, parent)
, m_adaptor(this)
, m_settings(SettingsWatcher::instance())
, m_repeatsRequired(0)
, m_state(Idle)
, m_lockState(DeviceLock::Undefined)
{
......@@ -181,13 +182,15 @@ void HostDeviceLock::enterSecurityCode(const QString &code)
case EnteringNewSecurityCode:
m_newCode = code;
m_state = RepeatingNewSecurityCode;
m_repeatsRequired = 1;
feedback(AuthenticationInput::RepeatNewSecurityCode, -1);
break;
case ExpectingGeneratedSecurityCode:
if (m_generatedCode == code) {
m_newCode = code;
m_state = RepeatingNewSecurityCode;
feedback(AuthenticationInput::RepeatNewSecurityCode, -1);
m_repeatsRequired = 2;
feedback(AuthenticationInput::EnterNewSecurityCode, -1);
} else {
feedback(AuthenticationInput::SecurityCodesDoNotMatch, QVariantMap());
feedback(AuthenticationInput::SuggestSecurityCode, generatedCodeData());
......@@ -210,6 +213,8 @@ void HostDeviceLock::enterSecurityCode(const QString &code)
break;
}
break;
} else if (--m_repeatsRequired > 0) {
feedback(AuthenticationInput::RepeatNewSecurityCode, -1);
} else {
setCodeFinished(setCode(m_currentCode, code));
}
......
......@@ -137,6 +137,7 @@ private:
QString m_currentCode;
QString m_newCode;
QString m_generatedCode;
int m_repeatsRequired;
State m_state;
DeviceLock::LockState m_lockState;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment