Skip to content

Commit

Permalink
[devicelock] Fix workflow for a forced security code change. Contribu…
Browse files Browse the repository at this point in the history
…tes to JB#37922
  • Loading branch information
adenexter committed Mar 15, 2017
1 parent 6388605 commit 78c707f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
11 changes: 7 additions & 4 deletions src/nemo-devicelock/host/hostauthenticator.cpp
Expand Up @@ -269,12 +269,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
27 changes: 18 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

0 comments on commit 78c707f

Please sign in to comment.