Skip to content

cannot modify user function for Facebook user #104

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
adamontherun opened this issue Jan 31, 2016 · 26 comments
Closed

cannot modify user function for Facebook user #104

adamontherun opened this issue Jan 31, 2016 · 26 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@adamontherun
Copy link

In iOS, with a normal (i.e. signed up with username and password) parse user, the following works:
[PFUser currentUser].username = @"newParseName";
[PFUser currentUser] save];

However, a user who authenticated via Facebook who performs

[PFUser currentUser].username = @"newFBName";
[PFUser currentUser] save];

will get the following error:

[Error]: cannot modify user function () {
return this.data.objectId || this.query.objectId;
} (Code: 206, Version: 1.12.0)

This 'cannot modify user function' error is returned for any changes you try to make to the current loggedin user when its a Facebook user.

@anthonylai
Copy link

Got the same issue.
This error also occurs when creating any objects in any classes. It just seems like the current user context is not set appropriately when a user is authenticated through facebook.

@ramymedhat
Copy link

I'm getting the same error with username/password login. It works fine right after the user signs in. But if the app is closed and reopened, it stops working.

@gfosco
Copy link
Contributor

gfosco commented Feb 1, 2016

Interesting.. Okay, we need to track down the root of this.

@gfosco gfosco added the type:bug Impaired feature or lacking behavior that is likely assumed label Feb 1, 2016
@jganzabal
Copy link

Same issue here, used the simple code to test it and got: POST http://localhost:8081/parse/classes/_User/9ihJFseG01 400 (Bad Request)

function initFacebookWithParse() {
window.fbAsyncInit = function() {
Parse.FacebookUtils.init({
appId: '1554770854736875',
xfbml: true,
version: 'v2.5'
});
};

(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {
        return;
    }
    js = d.createElement(s);
    js.id = id;
    js.src = "//connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

}

var currentUser;
function facebookLoginWithParse() {
if (!currentUser) {
Parse.FacebookUtils.logIn("email,public_profile", {
success: function(user) {
if (!user.existed()) {
console.log("User signed up and logged in through Facebook!");
FB.api('/me?fields=name,email', function(response) {
if (response.email) {
user.set("email", response.email);
}
user.save();
});
} else {
console.log("User logged in through Facebook!");
user.set("javaScriptLogin", true); //set anything to make sense on saving
user.save();
}
currentUser = user;
},
error: function(user, error) {
console.log(user);
console.log(error);
console.log("User cancelled the Facebook login or did not fully authorize.");
}
});
} else {
Parse.User.logOut();
Parse.User.currentAsync().then(function(user) {
currentUser = user;
console.log("logged out");
}, function(error) {
console.log("error");
console.log(error);
});

}

}

Logging in with user and password seems to work ok and lets me modify user

@viktor-skarlatov
Copy link

This happens because the server does not set the sessionToken of the user created by [PFUser become]. The server gets a session token, signs the user in and then returns the user without a valid session token. This happens in the handleMe() function in users.js. After fixing this I hit another brick but I haven't solved it yet. I will post more info as soon as I figure out a solution.

@Spacelapp
Copy link

Any news on this?

@edvincandon
Copy link

Check #173 -> it's been merged
Haven't tested it yet to see if that fixes the cannot modify user function issue

@edvincandon
Copy link

Just tested the #173, works like a charm. Now able to update_User object without any errors.
Note: I had to manually delete my _User and _Session schema for it to work properly.

Thanks @taylorstine !

@taylorstine
Copy link
Contributor

@edvincandon 👍

@jganzabal
Copy link

Thanks @taylorstine ! Worked for me too after deleting _User and _Session schema.

@adamontherun
Copy link
Author

this is resolved.

@DrBeak1
Copy link

DrBeak1 commented Mar 7, 2016

This still seems to be an issue for me. If I log in with Facebook, every call returned is 'cannot modify user'. Unfortunately I cannot delete my schemas because the app is live. Is there any way to fix this? I even tried using Parse.Cloud.useMasterKey() in my user beforeSave cloud code, but the issue still occurs.

@ryderjack
Copy link

@DrBeak1 same issue - deleting _User and _Session didn't help either

@DrBeak1
Copy link

DrBeak1 commented Mar 8, 2016

@ryderjack ya I'm finding there seems to be a lot of issues here. I posted more details about exactly what is happening for me here: #880

Hoping to get some feedback from someone. I'm an obj-c/java dev with only a little bit of node experience but enough to be helpful I suspect.

@cid2105
Copy link

cid2105 commented Mar 8, 2016

i'm also having issues. it seems that my a new user is created via facebook every time I log in through facebook.. very frustrating.

@DrBeak1
Copy link

DrBeak1 commented Mar 8, 2016

@cid2105 did you see the other issue I posted (#880)? I was able to get around the issue of multiple users being created for the same facebook account by removing any beforeSave cloud code for the User model. Are you using a beforeSave trigger?

Not that removing the beforeSave is a real solution, but knowing it plays a part in this could help decipher what is going on.

@cid2105
Copy link

cid2105 commented Mar 9, 2016

@DrBeak1 unfortunately, deleting the beforeSave triggers isnt an option for me. Although I can modify my facebook users now, signing in creates a new user each time. very frustrating...

@DrBeak1
Copy link

DrBeak1 commented Mar 9, 2016

@cid2105 , very strange. I'm having the opposite issue after removing beforeSave: no new users, but cannot modify current. Out of curiosity, what client are you using to modify/sign in? iOS, javascript, android, etc? Just to be thorough, I'm using parse 1.7.1, parse-server 2.1.4, and ios parse 1.12.0.

@cid2105
Copy link

cid2105 commented Mar 12, 2016

my issue disappeared after upgrading to parse-server 2.1.6

@mikepaggi
Copy link

Had to upgrade Parse Server to 2.1.6 and destroy my _User and _Schema for it to work for allowing me to modify my user data after authenticating through Facebook.

@flovilmart
Copy link
Contributor

Destroy The _User database? Was there some problems with the columns types?

@mikepaggi
Copy link

Not sure...but I took the suggestion from someone above. I'm starting pretty fresh so I don't have anything quite yet except my test database so it was the quick fix for me... For some reason previous to updating to 2.1.6 and destroying the _User database I would get an error from the iOS debugging side around not being able to edit the user.

@flovilmart
Copy link
Contributor

Alright, what matters now is that everything is rolling fine

@mikepaggi
Copy link

Yup all works now for me. Not stuck anymore :-) I thought it was me...

@highthem
Copy link

hi,

The issue is still there

parse server 2.10
ios sdk 1.13
android sdk 1.13.1

@srameshr
Copy link
Contributor

The issue still exists. Cannot modify for the subsequent signups after the first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests