added id generator to the asynckeysauth class

This commit is contained in:
Andrei Yankovich 2022-03-10 21:34:17 +03:00
parent 3f7550796c
commit b093d72f9a
2 changed files with 14 additions and 3 deletions

View File

@ -35,9 +35,7 @@ bool AsyncKeysAuth::auth(int allowedTimeRangeSec, QString* userId) const {
bool result = checkSign(data, _signature, _publicKey);
if (result && userId) {
*userId = QCryptographicHash::hash(_publicKey,
QCryptographicHash::Sha256).
toBase64(QByteArray::Base64UrlEncoding);
*userId = getUserId();
}
return result;
@ -79,6 +77,12 @@ bool AsyncKeysAuth::isValid() const {
return _publicKey.size() && _signature.size() && _unixTime;
}
QString AsyncKeysAuth::getUserId() const {
return QCryptographicHash::hash(_publicKey,
QCryptographicHash::Sha256).
toBase64(QByteArray::Base64UrlEncoding);
}
void AsyncKeysAuth::setSignature(const QByteArray &newSignature) {
_signature = newSignature;
}

View File

@ -108,6 +108,13 @@ public:
*/
bool isValid() const;
/**
* @brief getUserId This method return user id that generated from the public key.
* @note This function works slow, because this object does not contain ID of user. The user ID will be generated every invoke of this function
* @return user ID.
*/
QString getUserId() const;
protected:
/**