User Preferences: invalid response to update preferences - login of user failed

I am having a problem solving this ticket as I keep getting the duplicated email errror.
The test is passing, but it is failing on the status page. The following is the stack trace I am getting:

And bellow is my current session creation code:

Thank you, kindly
Luis Oscar Trigueiros

1 Like

What you trying to achieve should be done with an upsert: Update an existing document or insert it if it does not exist.

Don’t forget that on update you must specify what you want to update. The following link will help you determine what you get invalid field jwt. The link of for the shell but the logic for $set is the same.

https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/

1 Like

Hi @steevej-1495:
I have tried the update with upsert before but but I always got the invalid BSON field error.

Please go read the posted link. You will see with jwt is not valid at this place.

2 Likes

Hi @steevej-1495:

Thank you it is working now. :fu:

Another happy customer. B-)

1 Like

Hi All, can you please suggest what is going wrong.
I have got this exception:


2019-02-24 16:40:14.616 ERROR 14524 — [nio-5000-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: invalid hexadecimal representation of an ObjectId: [foobar]] with root cause

java.lang.IllegalArgumentException: invalid hexadecimal representation of an ObjectId: [foobar]

I have added output to getMovie in MovieController.java to highlight the issue cause - this is “foobar” text value.
Can you please suggest how I can avoid this issue? May be it was added intentionally and I should handle it? I am asking about this point, because I fount correct _id’s across *.js files and cannot realize if make something wrong or miss some point.

Thank you in advance!

I do not know if my solution is correct.
However, I have added check in getMovie() in MovieController class on to movieId length property.

I have the same issue, you has find the solution for this?

I solved this problem by adding a validation in UserDao.createUserSession, if the session already exists then I return true, otherwise I create a new one.

2 Likes

Thanks, It resolved my issue.

Hello, probably that is not what you want (in a closest to real world scenario) because you should replace user session jwt (it expires). You may achieve that using the replaceOne method on createSession instead of update. That will always replace the session for the user. Don’t forget to set upsert to true in the ReplaceOptions because if you don’t you will have problems on user creating sessions for the first time.

1 Like

It may be, initially I considered multiple sessions per user, so I worked with an insert, but when the test unit failed, I solved this problem in this way. The user stories are not very descriptive about schemes or business model. But on the other hand, it’s good to stumble with the code. Have a good day and thank you for your comment.

Thanks it resolved my issue :grinning:

1 Like