mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-04-29 11:14:37 +00:00
added id generator to the asynckeysauth class
This commit is contained in:
parent
3f7550796c
commit
b093d72f9a
@ -35,9 +35,7 @@ bool AsyncKeysAuth::auth(int allowedTimeRangeSec, QString* userId) const {
|
|||||||
bool result = checkSign(data, _signature, _publicKey);
|
bool result = checkSign(data, _signature, _publicKey);
|
||||||
|
|
||||||
if (result && userId) {
|
if (result && userId) {
|
||||||
*userId = QCryptographicHash::hash(_publicKey,
|
*userId = getUserId();
|
||||||
QCryptographicHash::Sha256).
|
|
||||||
toBase64(QByteArray::Base64UrlEncoding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -79,6 +77,12 @@ bool AsyncKeysAuth::isValid() const {
|
|||||||
return _publicKey.size() && _signature.size() && _unixTime;
|
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) {
|
void AsyncKeysAuth::setSignature(const QByteArray &newSignature) {
|
||||||
_signature = newSignature;
|
_signature = newSignature;
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isValid() const;
|
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:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user