mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-27 19:06:19 -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;
|
||||
}
|
||||
|
||||
int Entry::getPasswordAgeInDays() const
|
||||
int Entry::getPasswordAge() const
|
||||
{
|
||||
QListIterator<Entry*> i(m_history);
|
||||
i.toBack();
|
||||
@ -253,9 +253,9 @@ int Entry::getPasswordAgeInDays() const
|
||||
}
|
||||
if (!curr) {
|
||||
// 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
|
||||
|
@ -116,7 +116,7 @@ public:
|
||||
QString path() const;
|
||||
const QSharedPointer<PasswordHealth> passwordHealth();
|
||||
const QSharedPointer<PasswordHealth> passwordHealth() const;
|
||||
int getPasswordAgeInDays() const;
|
||||
int getPasswordAge() const;
|
||||
bool excludeFromReports() const;
|
||||
void setExcludeFromReports(bool state);
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "Group.h"
|
||||
#include "PasswordHealth.h"
|
||||
#include "Tools.h"
|
||||
#include "zxcvbn.h"
|
||||
|
||||
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.
|
||||
int age = entry->getPasswordAgeInDays();
|
||||
int ageInYears = age / 365;
|
||||
if (ageInYears > 1) {
|
||||
health->addScoreReason(QObject::tr("Password is %1 year(s) old", "", ageInYears).arg(ageInYears));
|
||||
int ageInSeconds = entry->getPasswordAge();
|
||||
// (365 days)(24 hours/day)(3600 s/hr) is approximately a year and gets compiled away.
|
||||
// Unfortunately, Qt doesn't seem to have a utility for this.
|
||||
if (ageInSeconds / (365 * 24 * 3600) > 1) {
|
||||
Tools::humanReadableTimeDifference(ageInSeconds);
|
||||
health->addScoreReason(QObject::tr("Password is %1 old").arg(Tools::humanReadableTimeDifference(ageInSeconds)));
|
||||
}
|
||||
|
||||
// Return the result
|
||||
|
Loading…
x
Reference in New Issue
Block a user