Skip to content

Fix for not working user login & creation #7

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
44 changes: 31 additions & 13 deletions lib/parse_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'parse_http_client.dart';
class User implements ParseBaseObject {
final String className = '_User';
final ParseHTTPClient client = ParseHTTPClient();
String path = "/parse/classes/_User";
String path = "/classes/_User";
Map<String, dynamic> objectData = {};

static ParseUserData userData;
Expand Down Expand Up @@ -70,26 +70,44 @@ class User implements ParseBaseObject {
objectData = {}..addAll(objectData)..addAll(objectInitialData);
}
_resetObjectId();
print(objectData);
final response = this.client.post("${client.data.serverUrl}$path",

Map<String, dynamic> bodyData = {};
bodyData["email"] = userData.username;
bodyData["password"] = userData.password;
bodyData["username"] = userData.username;

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

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

final response = this.client.post(url,
headers: {
'X-Parse-Revocable-Session': "1",
},
body: JsonEncoder().convert(objectData));
body: JsonEncoder().convert(bodyData));

return response.then((value) {
_handleResponse(value.body);
return objectData;
});
}

Future<Map<String, dynamic>> login() async {

Uri url = new Uri(
path: "${client.data.serverUrl}/parse/login",
queryParameters: {
"username": userData.username,
"password": userData.password
});
Uri tempUri = Uri.parse(client.data.serverUrl);

Uri url = Uri(
scheme: tempUri.scheme,
host: tempUri.host,
path: "${tempUri.path}/login",
queryParameters: {
"username": userData.username,
"password": userData.password
}
);

final response = this.client.post(url, headers: {
'X-Parse-Revocable-Session': "1",
Expand All @@ -102,7 +120,7 @@ class User implements ParseBaseObject {

Future<Map<String, dynamic>> verificationEmailRequest() async {
final response = this.client.post(
"${client.data.serverUrl}/parse/verificationEmailRequest",
"${client.data.serverUrl}/verificationEmailRequest",
body: JsonEncoder().convert({"email": userData.emailAddress}));
return response.then((value) {
return _handleResponse(value.body);
Expand All @@ -111,7 +129,7 @@ class User implements ParseBaseObject {

Future<Map<String, dynamic>> requestPasswordReset() async {
final response = this.client.post(
"${client.data.serverUrl}/parse/requestPasswordReset",
"${client.data.serverUrl}/requestPasswordReset",
body: JsonEncoder().convert({"email": userData.emailAddress}));
return response.then((value) {
return _handleResponse(value.body);
Expand Down