Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/src/base/parse_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const String keyLibraryName = 'Flutter Parse SDK';
// End Points
const String keyEndPointUserName = '/users/me';
const String keyEndPointLogin = '/login';
const String keyEndPointLogout = '/logout';
const String keyEndPointUsers = '/users';
const String keyEndPointVerificationEmail = '/verificationEmailRequest';
const String keyEndPointRequestPasswordReset = '/requestPasswordReset';
Expand Down
1 change: 1 addition & 0 deletions lib/src/enums/parse_enum_api_rq.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum ParseApiRQ {
currentUser,
signUp,
login,
logout,
loginAnonymous,
verificationEmailRequest,
requestPasswordReset,
Expand Down
34 changes: 29 additions & 5 deletions lib/src/objects/parse_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,35 @@ class ParseUser extends ParseObject implements ParseCloneable {
}
}

/// Removes the current user from the session data
logout() {
_client.data.sessionId = null;
unpin(key: keyParseStoreUser);
setObjectData(null);
/// Sends a request to delete the sessions token from the
/// server. Will also delete the local user data unless
/// deleteLocalUserData is false.
logout({bool deleteLocalUserData = true}) async {
if (deleteLocalUserData) {
_client.data.sessionId = null;
unpin(key: keyParseStoreUser);
setObjectData(null);
}

try {
if (username == null) return null;

Uri tempUri = Uri.parse(_client.data.serverUrl);

Uri url = Uri(
scheme: tempUri.scheme,
host: tempUri.host,
path: "${tempUri.path}$keyEndPointLogout");

final response = await _client.post(
url,
);

return _handleResponse(
this, response, ParseApiRQ.logout, _debug, className);
} on Exception catch (e) {
return _handleException(e, ParseApiRQ.logout, _debug, className);
}
}

/// Sends a verification email to the users email address
Expand Down