Backendless Support
 
Solved

Only Backendless.User accepted backendless.min.js:45

The situtationis is as follows:

the user logins and then updates his profile with this code:

  1. user.name = "dan";
  2. Backendless.UserService.update(user);

it works perfect.

if the user exits and initiates the app again (the stayloggedin parameter is set to true) this code is executed

  1. Backendless.initApp(APPLICATION_ID, SECRET_KEY, VERSION);
  2. if(Backendless.UserService.getCurrentUser()!== null)
  3. {
  4. user = Backendless.UserService.getCurrentUser();
  5. }

and then tries to update his profile with the code mentioned at the beggining, the following eror shows up:

Only Backendless.User accepted (at backendless.min.js:45)

i've printed the user object in the first case and second case. They only differ in the property user-token, which the first one doesn't have. I've tried deleting the property with

  1. delete user['user-token'];

Both users (the one before reload and afterwards) are the same. But i still get the same error.

Finally i have tried also asynchronous:

  1. Backendless.UserService.update( user, new Backendless.Async( userUpdated, gotError ) );

it does not work either.

I suspect it has something to to with the Backendless.UserService.getCurrentUser() after the call to Backendless.initApp

Leave a Comment

Comments (45)

photo
1

Could you please try this:

  1. Run your code with this script instead of backendless.min.js:

    http://api.backendless.com/sdk/js/latest/backendless.js

  2. Take screenshots in Chrome's Network tab of what the browser sends for the update request in both cases. Please post the screenshots here.

Thanks,

Mark

photo
1

There are no outgoing messages for the error call. The error is now on line 1329

thanks,

Nicolas

photo
1

What is the line number where the second call fails? Can you catch the stack trace for it in Chrome?

photo
1

Sure,

Uncaught Error: Only Backendless.User accepted backendless.js:1329

UserService.update backendless.js:1329

photo
1

Based on the code it looks like the object in the update() call is not an instance of Backendless.User. We will have to look into it. It appears the object is not retrieved from LocalCache properly

photo
1

Alright,

Thanks for your asistance

Best regards

Nicolas

photo
1

Hi Mark,

Is the fix for this scheduled for the next release? If so, when will it be?

Best regards,

Nicolas

photo
1

Hi Nicolas,

I believe it is fixed. Could you please try with:

http://api.backendless.com/sdk/js/latest/backendless.min.js

or

http://api.backendless.com/sdk/js/latest/backendless.js

Regards,

Mark

photo
1

Well, there is a big problem. The stay logged in option is not working.

According to the new documentation the way to validate if a user token is valid is by using

  1. var userTokenIsValid = Backendless.UserService.isValidLogin();

Upon reentering the app i get the token is true, yet the user variable remains as undefined. Where should i load the user from?

photo
1

By the way, there is a error in the documentation.

at the beginning it says

  1. Backendless.UserService.getCurrentUser();

but then it says

  1. Backendless.UserService.CurrentUser();

The first one is the correct one, albeit it doesn't work

photo
1

Nicolas,

The script works. The problem is in the doc. I will update it in a minute.

See this (and try the code there):

http://jsfiddle.net/hutwj1mx/

Please let me know once you try it so I can delete the app (the app-id and secret key are exposed..)

I will update the doc in a minute.

Regards,

Mark

photo
1

It works, thank you Mark :)

photo
1

I spoke to soon. Now it recovers the user object properly from the local storage, however it does not allow me to update the user. The same problem as the beginning of the thread:

Error: Only Backendless.User accepted

photo
1

You're right. I played with it some more and the object from the local cache is returned untyped, which is the root cause of the problem. I will escalate this problem and it will be fixed asap.

I apologize it is taking us so long..

photo
1

Nicolas,

Here's how it is going to work:

  1. Backendless.UserService.isValidLogin() - will return true or false whether the current user-token is valid. If it is valid, then the user does not need to re-login and your app can proceed without it.
  2. Backendless.UserService.loggedInUser() - IF you set stayLoggedIn to true, this method will return user's objectId. We decided NOT to store user object on the client. You would need to retrieve it with an API call (see below)
  3. Backendless.Data.of( Backendless.User ).findById( objectId ) - retrieves Backendless.User object for the given user id. The argument is the result of method from (2).

The updated script will be on the site some time tomorrow.

Regards,

Mark

photo
1

Nicolas, the library has been updated on our site:

http://api.backendless.com/sdk/js/latest/backendless.js

http://api.backendless.com/sdk/js/latest/backendless.min.js

The doc will be updated next to reflect the changes.

photo
1

Mark, Sorry for the late answer.

Yes, finally, it works perfectly :)

Cheers!

photo
1

Hi Nicolas,

I am so glad to hear that. Thanks for confirming.

Cheers,

Mark

photo
1

While updating a user profile, which was working previously, i get this error:

  1. PUT https://api.backendless.com/v1/users/63BD4B15-809E-6A1F-XXXXXXXXXX 504 (Gateway Time-out) <html>
  2. <head><title>504 Gateway Time-out</title></head>
  3. <body bgcolor="white">
  4. <center><h1>504 Gateway Time-out</h1></center>
  5. <hr><center>nginx/1.4.2</center>
  6. </body>
  7. </html>

photo
1

please, try it now

photo
1

  1. var user = Backendless.UserService.login($scope.user.email, $scope.user.password, true);

    var currentUser = Backendless.LocalCache.get( "current-user" );

    console.log(currentUser);

Hello,

Yesterday's "currentUser" was returning the object correctly but today it returns "undefined". Did you change anything?

photo
1

Raul,

Please see my response here:

http://support.backendless.com/topic/only-backendless-user-accepted-backendless-min-js45#comment-2705

It explains how to get the current user object.

Regards,

Mark

photo
1

Working fine now :)

photo
1

I require your attention urgently.

Mark. The API is failing again. When i invoke the service with this code:

  1. if(Backendless.UserService.isValidLogin()===true)
  2. {
  3. var userObjectId = Backendless.UserService.loggedInUser();
  4. console.log(userObjectId);
  5. user = Backendless.Data.of( Backendless.User ).findById(userObjectId);
  6. }

Backendless.UserService.isValidLogin() returns true..

this returns undefined

Backendless.UserService.loggedInUser();

Then this returns an error saying "Invalid value for the "value" argument" . The argument must contain only string or object values

user = Backendless.Data.of( Backendless.User ).findById(userObjectId);

My app is in production on the stores and my clients are receiving this error upon registering in the app and using it again. It was working previously, it was a change on the server side.

photo
1

Hi Nicolas!

Please check your code again. We have updated library on site.

Sorry for this inconvenience.

Regards,

Kate.

photo
1

Hi Kate

It is still not working :(

If you want download the app https://play.google.com/store/apps/details?id=sitmap.cometealguito_1

https://itunes.apple.com/us/app/comete-alguito/id988105085?mt=8

Register yourself (click on the person icon) and then register. Close the app and then reopen it

photo
1

BTW, you meant that you adjusted the code on Backendless and the code above is no longer useful or that you made the previous method work as it was again?

photo
1

We updated this library on our site: http://api.backendless.com/sdk/js/latest/backendless.js

(also you can use this lib too: http://backendless.com/sdk/js/2.0.2/backendless.js).

Your app works with one of these libs?

photo
1

I have a sales meeting right now. I'll try as soon as I exit it.

The thing is that if it works with the Backendless api that is online and it is a problem of lack of backwards compatibility with the previous app version I'll have to recompile my app and send it for approval to the Appstore, where the average time for approval of any new version of an app is 9 days. That means my users and all the marketing campaign I'm doing now will be left with an useless up for 9 days.

photo
1

I can confirm that the error is solved with the new Backendless version (latest). Yet, i am left with the big problem of the 9 days wait, which i honestly cannot accept.

photo
1

Nicolas,

Please clarify what you meant by "error is solved"? Your app started working again without any changes? Or you still had to make changes on your side?

Regards,

Mark

photo
photo
1

The error still occurs within the app. If I change the Backendless.js in my development version it works great. Yet, my published app which has the previously running version does not work.

photo
1

I am instructing the team to revert the changes. This will go in effect in about 6 hours. I will be personally looking into this incident.

Could you please let me know under what conditions the error occurs (right now) in the app? I'd like to come up with ideas for a workaround.

My sincere apologies for the inconvenience this has caused.

Regards,

Mark

photo
photo
1

Mark. I sincerely appreciate your commitment to give the best technical support possible. The app will start to be used again by customers after 10 am (GMT -5).

Right now when a customer who has registered in the app tries to use the app again he or she is presented with an 'unexpected error' mesaage as the app tries to load the person's profile from the backendless service service (above code). This leaves the app unusable as he/she cannot load his account to login again, nor can they proceed within the app to make a payment (the main functionality of the app)

Tonight I'll send the app with the new .js to the Appstore so they publish it asap and you can roll your changes.

Once again. I appreciate your excelente support despite the incident.

Best regards,

Nicolas .

photo
1

Nicolas,

Before you republish the app, please check if it works with a specific version of the script. Using /latest is not a good idea. We strive to avoid backward compatibility changes, but as the practice shows these accidents happen.

Specific versions of the script are available at:

http://backendless.com/sdk/js/2.0/backendless.js

http://backendless.com/sdk/js/2.0.1/backendless.js

http://backendless.com/sdk/js/2.0.2/backendless.js

These will not be changing in the future.

Please let me know if any one of these work for you, so we can plan our course of action better.

Regards,

Mark

photo
1

That is a good advice, i chose the 2.02 as it works with my current code. Though the 2.0 also did the trick.

photo
1

Mark?

photo
photo
1

This morning the error is still occurring.

As a side note the version on the app dates to 11/06/2015.

This error might have have been occurring since last week. we only have actual confirmation of it happening since monday but we were unable to track the issue until yesterday.

photo
1

Hi Nicolas.

"This morning the error is still occurring.."

Which version of js sdk do you use in code?

Because in previous message you said:

"That is a good advice, i chose the 2.02 as it works with my current code."

Regards,

Kate.

photo
1

Hi Kate,

As Mark said, it is not a good idea to include the latest sdk in the new release i am going to submit to the appStore, thus i used the 2.02 for doing this submit.

Currently in my app in production the error is still ocurring. The .js that it uses was downloaded on the 10th of june.

photo
1

Nicolas,

Could you please check if your application (as it is in production) works with the following script?

http://backendless.com/sdk/js/2.0/backendless.js

If it does, we will put that script into /latest

Regards,

Mark

photo
photo
1

Hi Nicolas!

Could you try how works your app from store?

We made several changes on server side for resolving this issue.

Regards,

Kate.

photo
1

Hi Kate!

I can confirm the problem is solved for new users with the current app!

The error persist for existing ones as the info stored on the local Storage is flawed, but i do not see any way to solve that issue. So i guess that is the best we can get out of this situation.

Thanks to you and all the team for your assistance.

Best regards,

Nicolas.

photo
1

Hi,

I confirm that my app has been updated on the Appstore and thus the workaround putted in place for it can be disabled now.

Best regards,

Nicolas.