1

I'm good with registering users, login, etc. Now I'm getting into modifying users with:

this.backand.object.update('users', user.userId, user)

but I can see that only my table gets modified, while I'll also need to modify the "Registered Users" table existing in "Security & Auth > Registered Users".

I understand I might need to create a custom action...maybe "Before Update"? ...but I can't find documentation on how to modify that specific table (via API or via BackAnd actions).

Thank you.

ricricucit
  • 2,276
  • 2
  • 15
  • 19

1 Answers1

1

thanks for using Backand! We don't offer any methods via the SDK to update the registered users. You can use the HTTP object to send a call to the back-end's REST API directly, hitting the same URL that the SDK requests when creating a new user, but this isn't officially documented. In general, we try to limit direct modifications of the registered users table, as there are some security concerns regarding how frequently the data is accessed and modified, but you can access the users object directly via the /users URL. There is an article in our documentation at http://docs.backand.com/en/latest/apidocs/security/index.html#link-your-app-39-s-users-with-backand-39-s-registered-users that covers an automated process for making these kinds of changes - you should be able to adapt some of the server side code in that example to work with your use case.

One alternative that would work now would be to have any change in basic information (username, password, firstname, lastname) result in a new user being created, and you could then use a custom action to perform the migration to the new user, but that is unnecessarily complex. I will add a ticket for our developers to look at adding this registered user management functionality in the future.

Matt Billock
  • 129
  • 7
  • When you say back-end's REST API directly...do you mean: `https://api.backand.com/1/table/data/backandUsers/USER_ID_HERE/` ? I though about this, but wouldn't this require another type of auth...or Admin "level" ? – ricricucit Feb 16 '17 at 12:00
  • if that's the case...at the moment I can't even edit users from the back-end...and I get this: ````{"error":"The filter items must contain the property "value".", "at": {"object":"users","action":"Update Registered User","line":31,"column":4}}```` – ricricucit Feb 16 '17 at 12:13
  • not quite. Rather, it is a http request to https://api.backand.com/1/user/ - there's a somewhat obfuscated example in the docs: `var x = $http({method:"POST",url:CONSTS.apiUrl + "1/user" ,data:backandUser, headers: {"Authorization":userProfile.token, "AppName":userProfile.app}}); ` Replace `CONSTS.apiUrl` with the value from the new SDK - it is available in the new sdk as `Backand.defaults.apiUrl` - you'll need to construct the authentication headers. Example at http://docs.backand.com/en/latest/apidocs/security/index.html#link-your-app-39-s-users-with-backand-39-s-registered-users – Matt Billock Feb 16 '17 at 19:04
  • Isn't a `POST` gonna create a new user? – ricricucit Feb 17 '17 at 14:09
  • Yes, as expected, what you suggested attempts to create a new user. Using `PUT` shows me that the `PUT` method is not supported. – ricricucit Feb 17 '17 at 14:14
  • Yes, as I mentioned above we don't allow many edits to the registered users table, aside from those you can make yourself via the admin UI. I'll add a ticket in the system to support this functionality in the future.. – Matt Billock Feb 17 '17 at 18:01
  • Also, there may be a specific configuration issue with your app preventing you from editing the registered users property. I suggest contacting us via intercom on www.backand.com so that we can troubleshoot in-depth, if you have some time. – Matt Billock Feb 17 '17 at 18:04
  • I send very simple and clear requests using your SDK, and I can show you how. The problem is not having clear Docs on how to modify your "Registered Users" table...and as I was saying: Since yesterday I can't even modify users data using BackAnd_'s back-end.........Anyway I've contacted you via intercom, thank you. :) – ricricucit Feb 17 '17 at 18:27