Commit e086476d authored by Andrew den Exter's avatar Andrew den Exter

Merge branch 'jb37922' into 'master'

[devicelock] Fix workflow for a forced security code change. Contributes to JB#37922

See merge request !15
parents c527c4b8 5151b702
......@@ -112,7 +112,13 @@ bool HostAuthenticator::authorizeSecurityCodeSettings(unsigned long)
bool HostAuthenticator::isSecurityCodeSet() const
{
return availability() != HostAuthenticationInput::AuthenticationNotRequired;
switch (availability()) {
case HostAuthenticationInput::AuthenticationNotRequired:
case HostAuthenticationInput::SecurityCodeRequired:
return false;
default:
return true;
}
}
void HostAuthenticator::authenticate(
......@@ -174,6 +180,7 @@ void HostAuthenticator::handleChangeSecurityCode(const QString &client, const QV
switch (availability()) {
case AuthenticationNotRequired:
case SecurityCodeRequired:
m_state = EnteringNewSecurityCode;
authenticationStarted(Authenticator::SecurityCode, AuthenticationInput::EnterNewSecurityCode);
break;
......@@ -181,7 +188,6 @@ void HostAuthenticator::handleChangeSecurityCode(const QString &client, const QV
case CanAuthenticate:
authenticationStarted(Authenticator::SecurityCode, AuthenticationInput::EnterSecurityCode);
break;
case SecurityCodeRequired:
case ManagerLocked:
case TemporarilyLocked:
case PermanentlyLocked:
......@@ -269,12 +275,15 @@ void HostAuthenticator::enterSecurityCode(const QString &code)
feedback(AuthenticationInput::SecurityCodesDoNotMatch, -1);
if (availability() != AuthenticationNotRequired) {
switch (availability()) {
case AuthenticationNotRequired:
case SecurityCodeRequired:
m_state = EnteringNewSecurityCode;
feedback(AuthenticationInput::EnterSecurityCode, -1);
} else {
m_state = AuthenticatingForChange;
feedback(AuthenticationInput::EnterNewSecurityCode, -1);
break;
default:
m_state = AuthenticatingForChange;
feedback(AuthenticationInput::EnterSecurityCode, -1);
}
return;
......
......@@ -162,6 +162,7 @@ void HostDeviceLock::enterSecurityCode(const QString &code)
m_state = EnteringNewSecurityCode;
m_currentCode = code;
feedback(AuthenticationInput::SecurityCodeExpired, -1);
feedback(AuthenticationInput::EnterNewSecurityCode, -1);
break;
case SecurityCodeInHistory:
break;
......@@ -192,17 +193,23 @@ void HostDeviceLock::enterSecurityCode(const QString &code)
break;
case RepeatingNewSecurityCode:
if (m_newCode != code) {
m_currentCode.clear();
m_newCode.clear();
m_state = Authenticating;
feedback(AuthenticationInput::SecurityCodesDoNotMatch, -1);
feedback(AuthenticationInput::EnterNewSecurityCode, -1);
} else {
// With disk encryption enabled changing the code can take a few seconds, don't leave
// the user hanging.
m_newCode.clear();
switch (availability()) {
case AuthenticationNotRequired:
case SecurityCodeRequired:
m_state = EnteringNewSecurityCode;
feedback(AuthenticationInput::EnterNewSecurityCode, -1);
break;
default:
m_state = Authenticating;
feedback(AuthenticationInput::EnterSecurityCode, -1);
break;
}
break;
} else {
setCodeFinished(setCode(m_currentCode, code));
}
break;
......@@ -250,7 +257,7 @@ void HostDeviceLock::setCodeFinished(int result)
case Success:
qCDebug(daemon, "Lock code changed.");
m_currentCode.clear();
if (m_state == ChangingSecurityCode) {
if (m_state == ChangingSecurityCode || m_state == RepeatingNewSecurityCode) {
unlockFinished(unlockWithCode(m_newCode));
} else if (m_state == Canceled) {
m_state = Idle;
......@@ -258,6 +265,8 @@ void HostDeviceLock::setCodeFinished(int result)
authenticationEnded(false);
unlockingChanged();
} else {
abortAuthentication(AuthenticationInput::SoftwareError);
}
break;
case SecurityCodeInHistory:
......@@ -362,6 +371,9 @@ void HostDeviceLock::stateChanged()
case PermanentlyLocked:
m_lockState = DeviceLock::PermanentLockout;
break;
case SecurityCodeRequired:
m_lockState = DeviceLock::Locked;
break;
default:
m_lockState = isLocked()
? DeviceLock::Locked
......
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