Update User's Custom Property After Registration

Hi,

I am having the following situtaion
1.) User registered in into Backendless Server successfully

2.) There is a handler named afterRegister.js which is getting successfully called

3.) Now a property which is a relation to the user object ("example : permissions ") needs to be modified in the server side dynamically

Backendless.ServerCode.User.afterLogin(function(req, res) {
  //add your code here
    var logger = Backendless.Logging.getLogger( "AfterLogin");
     logger.debug(" REQ " + JSON.stringify(req)); 
    logger.debug(new Date() + " -  RES  - " + JSON.stringify(res)); 
   
    if (res.result) {
      var user =  req.context;
        user.name = "TANMAY MANDAL";
        user.setProperty( "name", "Spidey Man" );
        
        return Backendless.UserService.update(user);
  }

Could you please give me a hint how to update the user by the hook.

Thank you very much in advance.

Best Regards

Tanmay

Hi Tanmay,

What exactly doesn’t work in the code sample you demonstrated?

Hello ,

Sorry to say that the name is not changed.

Are you talking about the result you receive on client?
Also, why do you set the name two times?

My requirement is very very simple.

When a user register I want to place the user in a particular group.

I have already created data object called “Role” and a column named “permissions” in User object.

After register the user will be placed in a group. I have tried a lot of ways but failed. How can I set user.permissions ?

~
Tanmay

Please check the documentation on how to work with the Data Service, the workflow is pretty much the same from the Business Logic.

According to our Support Policy, helping you to build your app is not a free support option.