Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow implementations to return a locked out condition.
  • Loading branch information
adenexter committed Jan 19, 2017
1 parent 6b349fd commit 1d135e2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/nemo-devicelock/host/hostauthenticationinput.h
Expand Up @@ -70,7 +70,8 @@ class HostAuthenticationInput : public HostObject
Failure = -1,
SecurityCodeExpired = -2,
SecurityCodeInHistory = -3,
Evaluating = -4
LockedOut = -4,
Evaluating = -5
};

enum Availability {
Expand All @@ -93,8 +94,8 @@ class HostAuthenticationInput : public HostObject
// AuthenticationInput
virtual bool authorizeInput(unsigned long pid);

int maximumAttempts() const;
int currentAttempts() const;
virtual int maximumAttempts() const;
virtual int currentAttempts() const;

virtual void enterSecurityCode(const QString &code) = 0;
void cancel() override = 0;
Expand Down
14 changes: 12 additions & 2 deletions src/nemo-devicelock/host/hostauthenticator.cpp
Expand Up @@ -211,18 +211,28 @@ void HostAuthenticator::enterSecurityCode(const QString &code)
return;
case Authenticating:
qCDebug(daemon, "Lock code entered for authentication.");
if ((attempts = checkCode(code)) == Success) {
switch ((attempts = checkCode(code))) {
case Success:
case SecurityCodeExpired:
confirmAuthentication();
return;
case LockedOut:
abortAuthentication(AuthenticationInput::LockedOut);
return;
}
break;
case AuthenticatingForChange:
qCDebug(daemon, "Lock code entered for code change authentication.");
if ((attempts = checkCode(code)) == Success) {
switch ((attempts = checkCode(code))) {
case Success:
case SecurityCodeExpired:
m_state = EnteringNewSecurityCode;
m_currentCode = code;
feedback(AuthenticationInput::EnterNewSecurityCode, -1);
return;
case LockedOut:
abortAuthentication(AuthenticationInput::LockedOut);
return;
}
break;
case EnteringNewSecurityCode:
Expand Down
3 changes: 3 additions & 0 deletions src/nemo-devicelock/host/hostdevicelock.cpp
Expand Up @@ -143,6 +143,9 @@ void HostDeviceLock::enterSecurityCode(const QString &code)
break;
case SecurityCodeInHistory:
break;
case LockedOut:
abortAuthentication(AuthenticationInput::LockedOut);
break;
default: {
const int maximum = maximumAttempts();

Expand Down
2 changes: 1 addition & 1 deletion src/nemo-devicelock/host/hostdevicelock.h
Expand Up @@ -78,7 +78,7 @@ class HostDeviceLock : public HostAuthenticationInput

bool isUnlocking() const;

int automaticLocking() const;
virtual int automaticLocking() const;

void unlock();
void enterSecurityCode(const QString &code) override;
Expand Down

0 comments on commit 1d135e2

Please sign in to comment.