-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.cpp
70 lines (57 loc) · 1.26 KB
/
user.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "user.hpp"
#include <QString>
#include <QMap>
#include <QUrlQuery>
#include <QNetworkRequest>
User::User(QString name, QString password, QString email)
{
setName(name);
setPassword(password);
setEmail(email);
}
void User::setName(QString name)
{
mUser.insert("username",name);
}
void User::setPassword(QString password)
{
mUser.insert("password",password);
}
void User::setEmail(QString email)
{
mUser.insert("email",email);
}
QString User::getName()const
{
return mUser.value("username","");
}
QString User::getPassword()const
{
return mUser.value("password","");
}
QString User::getEmail()const
{
return mUser.value("email","");
}
void User::addName(QUrlQuery &url_query)
{
url_query.addQueryItem("username",getName());
}
void User::addEmail(QUrlQuery &url_query)
{
url_query.addQueryItem("email",getEmail());
}
void User::addPassword(QUrlQuery &url_query)
{
url_query.addQueryItem("password",getPassword());
}
void User::addAll(QUrlQuery &url_query)
{
addName(url_query);
addEmail(url_query);
addPassword(url_query);
}
void User::addAuth(QNetworkRequest &request)
{
request.setRawHeader("Authorization","Basic " + QByteArray(QString("%1:%2").arg(getName()).arg(getPassword()).toUtf8()).toBase64());
}