File indexing completed on 2024-12-01 13:09:18
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "servicepassword.h" 0008 0009 ServicePassword::ServicePassword() = default; 0010 0011 ServicePassword::~ServicePassword() = default; 0012 0013 bool ServicePassword::operator==(const ServicePassword &other) const 0014 { 0015 return mEmail2faEnabled == other.email2faEnabled() && mPassword == other.password() && mTotp == other.totp(); 0016 } 0017 0018 void ServicePassword::parseService(const QJsonObject &replyObject) 0019 { 0020 const QJsonObject email2faJson = replyObject.value(QStringLiteral("email2fa")).toObject(); 0021 if (!email2faJson.isEmpty()) { 0022 mEmail2faEnabled = email2faJson.value(QStringLiteral("enabled")).toBool(); 0023 } 0024 const QJsonObject passwordJson = replyObject.value(QStringLiteral("password")).toObject(); 0025 if (!passwordJson.isEmpty()) { 0026 mPassword = passwordJson.value(QStringLiteral("bcrypt")).toString(); 0027 } 0028 const QJsonObject totpJson = replyObject.value(QStringLiteral("totp")).toObject(); 0029 if (!totpJson.isEmpty()) { 0030 mTotp = totpJson.value(QStringLiteral("enabled")).toBool(); 0031 } 0032 } 0033 0034 bool ServicePassword::email2faEnabled() const 0035 { 0036 return mEmail2faEnabled; 0037 } 0038 0039 void ServicePassword::setEmail2faEnabled(bool email2faEnabled) 0040 { 0041 mEmail2faEnabled = email2faEnabled; 0042 } 0043 0044 QString ServicePassword::password() const 0045 { 0046 return mPassword; 0047 } 0048 0049 void ServicePassword::setPassword(const QString &password) 0050 { 0051 mPassword = password; 0052 } 0053 0054 bool ServicePassword::totp() const 0055 { 0056 return mTotp; 0057 } 0058 0059 void ServicePassword::setTotp(bool totp) 0060 { 0061 mTotp = totp; 0062 } 0063 0064 QDebug operator<<(QDebug d, const ServicePassword &t) 0065 { 0066 d << "mEmail2faEnabled " << t.email2faEnabled(); 0067 d << "mPassword " << t.password(); 0068 d << "mTotp " << t.totp(); 0069 return d; 0070 }