Skip to content
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

[BUG] /api/v1/users.updateOwnBasicInfo not working properly #11154

Closed
filipealva opened this issue Jun 15, 2018 · 7 comments
Closed

[BUG] /api/v1/users.updateOwnBasicInfo not working properly #11154

filipealva opened this issue Jun 15, 2018 · 7 comments
Assignees
Projects
Milestone

Comments

@filipealva
Copy link
Contributor

When trying to set a username for a new user on a server with customFields enabled the API is returning the following response:

[REST][RESULT][https://rafaelks.rocket.chat/api/v1/users.updateOwnBasicInfo]: {
  "error" : "Cannot read property 'role' of undefined",
  "success" : false
}.

The problem is: It says that the request has failed (success: false) but it's a false positive because the username is actually set, so the request has updated the user info and so it was successful.

@sampaiodiego
Copy link
Member

what are the customFields configured?

@filipealva
Copy link
Contributor Author

filipealva commented Jun 15, 2018

@sampaiodiego

  • Role (teacher, student)
  • Twitter

I think that these are the default ones suggested on the docs.

I'm using https://rafaelks.rocket.chat/ for testing, if you want to take a look.

@rafaelks
Copy link
Contributor

This is what happens, when trying to signup in any client with custom fields and setting a username (there's no way to signup with one API, we need to use two):

simulator screen shot - iphone se - 2018-06-15 at 13 07 16

@sampaiodiego
Copy link
Member

@filipealva can you please post the JSON used to configure the custom fields?

also can you send the exactly request payloads and responses? thx

@rafaelks
Copy link
Contributor

@sampaiodiego

{
    "role": {
        "type": "select",
        "defaultValue": "student",
        "options": ["teacher", "student"],
        "required": true,
        "modifyRecordField": {
            "array": true,
            "field": "roles"
        }
    },
    "twitter": {
        "type": "text",
        "required": true,
        "minLength": 2,
        "maxLength": 10
    }
}

@filipealva
Copy link
Contributor Author

@sampaiodiego

  1. First we grab the user info from the fields and send a signup request to the RealTime API with the following payload:
{
  "method" : "registerUser",
  "id" : "jMJm7kaA60IROhyXNcK24B2QRT3hjfszOXZfxNuA5xxn7kVuqe",
  "params" : [
    {
      "name" : "test0111",
      "email" : "test0111@test.com",
      "pass" : "123456",
      "role" : "student",
      "twitter" : "filipealva"
    }
  ],
  "msg" : "method"
}
  1. It succeeds with no error.

  2. We authenticate the user we've just created:

[REST][REQUEST]: https://rafaelks.rocket.chat/api/v1/login: {
  "user" : {
    "email" : "test0111@test.com"
  },
  "password" : {
    "algorithm" : "sha-256",
    "digest" : "8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92"
  }
}
  1. It succeeds with no error.
[REST][RESULT][https://rafaelks.rocket.chat/api/v1/login]: {
  "status" : "success",
  "data" : {
    "authToken" : "VwPdFJd6A_ecU8u67O7FVJGA-9rjy76_otmljVFnsyt",
    "userId" : "G5A9eDDQYFMQhtqsb",
    "me" : {
      "status" : "offline",
      "name" : "test0111",
      "_id" : "G5A9eDDQYFMQhtqsb",
      "settings" : {
        "preferences" : {
          "newRoomNotification" : "door",
          "mergeChannels" : false,
          "collapseMediaByDefault" : false,
          "saveMobileBandwidth" : true,
          "roomCounterSidebar" : false,
          "sidebarViewMode" : "medium",
          "sidebarShowUnread" : false,
          "hideUsernames" : false,
          "enableAutoAway" : false,
          "desktopNotificationDuration" : 0,
          "idleTimeoutLimit" : 300,
          "notificationsSoundVolume" : 100,
          "newMessageNotification" : "chime",
          "hideAvatars" : false,
          "desktopNotifications" : "mentions",
          "mobileNotifications" : "mentions",
          "useEmojis" : true,
          "hideFlexTab" : false,
          "unreadAlert" : true,
          "sidebarHideAvatar" : false,
          "sidebarShowFavorites" : true,
          "convertAsciiEmoji" : true,
          "messageViewMode" : 0,
          "autoImageLoad" : true,
          "emailNotificationMode" : "mentions",
          "audioNotifications" : "mentions",
          "roomsListExhibitionMode" : "category",
          "muteFocusedConversations" : true,
          "hideRoles" : false,
          "viewMode" : 0,
          "sendOnEnter" : "normal"
        }
      },
      "roles" : [
        "user",
        "student"
      ],
      "active" : true,
      "emails" : [
        {
          "verified" : false,
          "address" : "test0111@test.com"
        }
      ]
    }
  }
  1. Then we set the username of our new user:
[REST][REQUEST]: https://rafaelks.rocket.chat/api/v1/users.updateOwnBasicInfo: {
  "data" : {
    "username" : "test0111"
  }
}
  1. It returns this error:
[REST][RESULT][https://rafaelks.rocket.chat/api/v1/users.updateOwnBasicInfo]: {
  "error" : "Cannot read property 'role' of undefined",
  "success" : false
}

We have to chain these requests because our API doesn't support signing up the username on our first request, so we must signup the user, then authenticate him, then set its username. The process is messed up by definition but it usually works fine, the problem is happening only when setting a username when the server has custom fields enabled.

@rodrigok
Copy link
Member

Closed by #11204

June/2018 automation moved this from Review/QA to Closed Jun 22, 2018
HugoHeneault added a commit to HugoHeneault/docs that referenced this issue Dec 11, 2020
MartinSchoeler added a commit to RocketChat/docs-old that referenced this issue Mar 4, 2021
…orking (#1841)

As this bug is gone since RocketChat/Rocket.Chat#11154 was closed

Co-authored-by: Martin Schoeler <martin.schoeler@rocket.chat>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
June/2018
  
Closed
Development

No branches or pull requests

5 participants