Erudika / scoold-pro

Cloud-ready Q&A platform for the enterprise (self-hosted, on premise)
https://scoold.com
Other
7 stars 0 forks source link

Recreate user and profile using the old ID. #45

Closed jorgeag68 closed 3 years ago

jorgeag68 commented 3 years ago

Following ticket #44 and your suggestion: """ Changing the id of an object is not possible with an "update" operation. Instead you can copy the JSON data from one object and create a new object, paste the data and edit the id. Do this for both profile and user objects of that user. Finally, after you verify that all works well, delete the old objects. The id of a profile object is in the format 123456:profile """

Meanwhile I could create the new profile with the old id but can't create the user.

I get this error: { "code" : 400, "message" : "Failed to authenticate user with 'password'. Check if user is active." }

What can be done ?

albogdano commented 3 years ago

This was due to a bug in the Para web console and should be fixed now. Just refresh the page console.paraio.org

albogdano commented 3 years ago

If you see an error like "user with that identifier already exists" or "bad request" then try deleting the "new" user object which is already created and then recreate it by pasting the old JSON data but just change the id property to match the old user id

jorgeag68 commented 3 years ago

I've managed to add the user and the profile. However there are still some issues.

It's not possible to update the "Created by" field on the profile to match the user id.

I think this is the reason that some of the links to the user profile are incorrectly generated by the app.

On the users list: https://serve.xxx/profile/$%7BshowFriend.creatorid%7D/first-last (redirects to the currently logged in user profile)

On the list of questions: https://server.xxx/profile//first-last (redirects to the currently logged in user profile)

On the comments: https://server.xxx/profile/first-last (This causes an error 500 on the server)

Also, we don't see the user on the list of users on para web console.

Only by using the direct link we can see it. https://console.paraio.org/index.html#/user/show/1194289574411505664

albogdano commented 3 years ago

The creatorid in profile should be equal to the id in user. You can create the user object first then create a new user profile object by pasting the whole JSON object in the text box and edit creatorid there. Here's an example of a user and a profile:

{
  "id": "998904262459133952",
  "timestamp": 1548241919606,
  "type": "user",
  "updated": 1600194343855,
  "name": "User",
  "stored": true,
  "indexed": true,
  "cached": true,
  "identifier": "gp:110170934138224007978",
  "groups": "users",
  "active": true,
  "objectURI": "/user/998904262459133952",
  "identityProvider": "google"
}

and profile, created after the user object:

{
  "id": "998904262459133952:profile",
  "timestamp": 1548241919606,
  "type": "profile",
  "creatorid": "998904262459133952",
  "updated": 1548241920746,
  "name": "User",
  "stored": true,
  "indexed": true,
  "cached": true,
  "objectURI": "/profile/998904262459133952%3Aprofile",
  "plural": "profiles",
  "lastseen": 1548241920725
}
albogdano commented 3 years ago

Each question or comment from that user has a field creatorid: "998904262459133952:profile" and you must restore that id value to the new user and profile objects.

albogdano commented 3 years ago

If all else fails delete the two objects from Para and recreate them using Para CLI by pasting each JSON object inside a file, e.g. user.json and profile.json then execute para-cli create user.json --type user and para-cli create profile.json --type profile.

jorgeag68 commented 3 years ago

It worked now by creating the User first and then creating the Profile.

Thank you.