mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-28 11:26:11 -04:00
Switched to seconds for getPasswordAge for better reuse
This commit is contained in:
parent
1121488438
commit
f90483cc1f
@ -231,7 +231,7 @@ const QSharedPointer<PasswordHealth> Entry::passwordHealth() const
|
|||||||
return m_data.passwordHealth;
|
return m_data.passwordHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Entry::getPasswordAgeInDays() const
|
int Entry::getPasswordAge() const
|
||||||
{
|
{
|
||||||
QListIterator<Entry*> i(m_history);
|
QListIterator<Entry*> i(m_history);
|
||||||
i.toBack();
|
i.toBack();
|
||||||
@ -253,9 +253,9 @@ int Entry::getPasswordAgeInDays() const
|
|||||||
}
|
}
|
||||||
if (!curr) {
|
if (!curr) {
|
||||||
// If no change in history, password is from creation time
|
// If no change in history, password is from creation time
|
||||||
return this->timeInfo().creationTime().daysTo(QDateTime::currentDateTime());
|
return this->timeInfo().creationTime().secsTo(QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
return curr->timeInfo().lastModificationTime().daysTo(QDateTime::currentDateTime());
|
return curr->timeInfo().lastModificationTime().secsTo(QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entry::excludeFromReports() const
|
bool Entry::excludeFromReports() const
|
||||||
|
@ -116,7 +116,7 @@ public:
|
|||||||
QString path() const;
|
QString path() const;
|
||||||
const QSharedPointer<PasswordHealth> passwordHealth();
|
const QSharedPointer<PasswordHealth> passwordHealth();
|
||||||
const QSharedPointer<PasswordHealth> passwordHealth() const;
|
const QSharedPointer<PasswordHealth> passwordHealth() const;
|
||||||
int getPasswordAgeInDays() const;
|
int getPasswordAge() const;
|
||||||
bool excludeFromReports() const;
|
bool excludeFromReports() const;
|
||||||
void setExcludeFromReports(bool state);
|
void setExcludeFromReports(bool state);
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
#include "PasswordHealth.h"
|
#include "PasswordHealth.h"
|
||||||
|
#include "Tools.h"
|
||||||
#include "zxcvbn.h"
|
#include "zxcvbn.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@ -199,10 +200,12 @@ QSharedPointer<PasswordHealth> HealthChecker::evaluate(const Entry* entry) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fourth, reduce score by 5 for each year beyond one year old.
|
// Fourth, reduce score by 5 for each year beyond one year old.
|
||||||
int age = entry->getPasswordAgeInDays();
|
int ageInSeconds = entry->getPasswordAge();
|
||||||
int ageInYears = age / 365;
|
// (365 days)(24 hours/day)(3600 s/hr) is approximately a year and gets compiled away.
|
||||||
if (ageInYears > 1) {
|
// Unfortunately, Qt doesn't seem to have a utility for this.
|
||||||
health->addScoreReason(QObject::tr("Password is %1 year(s) old", "", ageInYears).arg(ageInYears));
|
if (ageInSeconds / (365 * 24 * 3600) > 1) {
|
||||||
|
Tools::humanReadableTimeDifference(ageInSeconds);
|
||||||
|
health->addScoreReason(QObject::tr("Password is %1 old").arg(Tools::humanReadableTimeDifference(ageInSeconds)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the result
|
// Return the result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user