@@ -152,7 +152,7 @@ class ParseUser extends ParseObject implements ParseCloneable {
152
152
keyVarPassword: password
153
153
});
154
154
155
- final response = await _client.post (url, headers: {
155
+ final response = await _client.get (url, headers: {
156
156
keyHeaderRevocableSession: "1" ,
157
157
});
158
158
@@ -163,6 +163,36 @@ class ParseUser extends ParseObject implements ParseCloneable {
163
163
}
164
164
}
165
165
166
+ // Logs in a user anonymously
167
+ Future <ParseResponse > loginAnonymous () async {
168
+ try {
169
+ Uri tempUri = Uri .parse (_client.data.serverUrl);
170
+
171
+ Uri url = Uri (
172
+ scheme: tempUri.scheme,
173
+ host: tempUri.host,
174
+ path: "${tempUri .path }$keyEndPointUsers " ,
175
+ );
176
+
177
+ var uuid = new Uuid ();
178
+
179
+ final response = await _client.post (url,
180
+ headers: {
181
+ keyHeaderRevocableSession: "1" ,
182
+ },
183
+ body: jsonEncode ({
184
+ "authData" : {
185
+ "anonymous" : {"id" : uuid.v4 ()}
186
+ }
187
+ }));
188
+
189
+ return _handleResponse (
190
+ this , response, ParseApiRQ .loginAnonymous, _debug, className);
191
+ } on Exception catch (e) {
192
+ return _handleException (e, ParseApiRQ .loginAnonymous, _debug, className);
193
+ }
194
+ }
195
+
166
196
/// Removes the current user from the session data
167
197
logout () {
168
198
_client.data.sessionId = null ;
@@ -210,7 +240,9 @@ class ParseUser extends ParseObject implements ParseCloneable {
210
240
var uri = _client.data.serverUrl + "$path /$objectId " ;
211
241
var body =
212
242
json.encode (toJson (forApiRQ: true ), toEncodable: dateTimeEncoder);
213
- final response = await _client.put (uri, body: body);
243
+ final response = await _client.put (uri,
244
+ headers: {keyHeaderSessionToken: _client.data.sessionId},
245
+ body: body);
214
246
return _handleResponse (
215
247
this , response, ParseApiRQ .save, _debug, className);
216
248
} on Exception catch (e) {
0 commit comments