Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

log in with token #59

Merged
merged 1 commit into from
Jan 28, 2019
Merged
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
12 changes: 9 additions & 3 deletions lib/src/objects/parse_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ class ParseUser extends ParseObject implements ParseCloneable {
/// Current user is stored locally, but in case of a server update [bool]
/// fromServer can be called and an updated version of the [User] object will be
/// returned
Future<ParseResponse> getCurrentUserFromServer() async {
Future<ParseResponse> getCurrentUserFromServer({token}) async {
// We can't get the current user and session without a sessionId
if (_client.data.sessionId == null) return null;
if(token == null && _client.data.sessionId == null) {
return null;
}

if(token == null){
token = _client.data.sessionId;
}

try {
Uri tempUri = Uri.parse(_client.data.serverUrl);
Expand All @@ -74,7 +80,7 @@ class ParseUser extends ParseObject implements ParseCloneable {
host: tempUri.host,
path: "${tempUri.path}$keyEndPointUserName");

final response = await _client.get(uri, headers: {keyHeaderSessionToken: _client.data.sessionId});
final response = await _client.get(uri, headers: {keyHeaderSessionToken: token});
return _handleResponse(response, ParseApiRQ.currentUser);
} on Exception catch (e) {
return _handleException(e, ParseApiRQ.currentUser);
Expand Down