Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb37922' into 'master'
[devicelock] Fix workflow for a forced security code change. Contributes to JB#37922

See merge request !15
  • Loading branch information
adenexter committed Mar 22, 2017
2 parents c527c4b + 5151b70 commit e086476
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
21 changes: 15 additions & 6 deletions src/nemo-devicelock/host/hostauthenticator.cpp
Expand Up @@ -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(
Expand Down Expand Up @@ -174,14 +180,14 @@ void HostAuthenticator::handleChangeSecurityCode(const QString &client, const QV

switch (availability()) {
case AuthenticationNotRequired:
case SecurityCodeRequired:
m_state = EnteringNewSecurityCode;
authenticationStarted(Authenticator::SecurityCode, AuthenticationInput::EnterNewSecurityCode);
break;
case CanAuthenticateSecurityCode:
case CanAuthenticate:
authenticationStarted(Authenticator::SecurityCode, AuthenticationInput::EnterSecurityCode);
break;
case SecurityCodeRequired:
case ManagerLocked:
case TemporarilyLocked:
case PermanentlyLocked:
Expand Down Expand Up @@ -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;
Expand Down
30 changes: 21 additions & 9 deletions src/nemo-devicelock/host/hostdevicelock.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -250,14 +257,16 @@ 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;

authenticationEnded(false);

unlockingChanged();
} else {
abortAuthentication(AuthenticationInput::SoftwareError);
}
break;
case SecurityCodeInHistory:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e086476

Please sign in to comment.