@@ -22,7 +22,7 @@ BackendlessUserAPI::BackendlessUserAPI(QNetworkAccessManager* _networkAccessMana
22
22
apiKey(_apiKey),
23
23
endpoint(_endpoint) {
24
24
readTokenFromDisk ();
25
- qDebug () << userToken ;
25
+ qDebug () << userTokenValue ;
26
26
}
27
27
28
28
void BackendlessUserAPI::registerUser (BackendlessRegisterUserRepresentable& user) {
@@ -72,7 +72,7 @@ void BackendlessUserAPI::signInUser(QString login, QString password) {
72
72
extractResult<BackendlessSignInUser>(
73
73
replyValue,
74
74
[&](auto user) {
75
- userToken = user.userToken ;
75
+ userTokenValue = user.userToken ;
76
76
saveTokenOnDisk ();
77
77
emit signInUserSuccess (user);
78
78
},
@@ -88,24 +88,25 @@ void BackendlessUserAPI::signInUser(QString login, QString password) {
88
88
);
89
89
}
90
90
91
+ QString BackendlessUserAPI::tokenFilePath () {
92
+ auto path = QStandardPaths::writableLocation (QStandardPaths::DocumentsLocation);
93
+ return path + " /backendless_token.txt" ;
94
+ }
95
+
91
96
void BackendlessUserAPI::readTokenFromDisk () {
92
- auto path = QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation);
93
- auto fileName = path + " /backendless_token.txt" ;
94
- QFile file (fileName);
97
+ QFile file (tokenFilePath ());
95
98
if (file.open (QIODevice::ReadOnly | QIODevice::Text)) {
96
99
QTextStream stream (&file);
97
- stream >> userToken ;
100
+ stream >> userTokenValue ;
98
101
}
99
102
file.close ();
100
103
}
101
104
102
105
void BackendlessUserAPI::saveTokenOnDisk () {
103
- auto path = QStandardPaths::writableLocation (QStandardPaths::AppLocalDataLocation);
104
- auto fileName = path + " /backendless_token.txt" ;
105
- QFile file (fileName);
106
+ QFile file (tokenFilePath ());
106
107
if (file.open (QIODevice::WriteOnly | QIODevice::Text)) {
107
108
QTextStream stream (&file);
108
- stream << userToken ;
109
+ stream << userTokenValue ;
109
110
}
110
111
file.close ();
111
112
}
@@ -114,7 +115,7 @@ void BackendlessUserAPI::validateUserToken() {
114
115
request (
115
116
networkAccessManager,
116
117
this ,
117
- endpoint + appId + " /" + apiKey + " /users/isvalidusertoken/" + userToken ,
118
+ endpoint + appId + " /" + apiKey + " /users/isvalidusertoken/" + userTokenValue ,
118
119
{
119
120
120
121
},
@@ -161,3 +162,7 @@ void BackendlessUserAPI::restorePassword(QString email) {
161
162
}
162
163
);
163
164
}
165
+
166
+ QString BackendlessUserAPI::userToken () {
167
+ return userTokenValue;
168
+ }
0 commit comments