All of my tests passed. But I have User Preferences: Cannot read property ‘preferences’ of undefined on my status page. What I shoud fix?
I have the same situation.
1 Like
I’ve faced with the same issue.
UPDATE:
I’ve finally solved it by changing implementation of addUser and createUserSession methods.
In addUser:
- You need to make sure that userId is valid. For example,
if (user == null || user.isEmpty()) {
throw new IncorrectDaoOperation("invalid user");
}
- You need to make sure that user with the same id doesn’t exist. For example,
final Bson filter = Filters.eq("email", user.getEmail());
if (usersCollection.find(filter).limit(1).first() == null) {
usersCollection.withWriteConcern(WriteConcern.MAJORITY).insertOne(user);
return true;
}
return false;
1 Like
What changes shoud I do in createUserSession?
I’d suggest you to validate that
- input arguments are not null
if (userId == null || jwt == null) {
return false;
}
- user with such id exists in database
if (getUser(userId) == null) {
return false;
}
- session for given user doesn’t exist
final Bson filter = Filters.eq("user_id", userId);
final Session oldSession = sessionsCollection.find(filter).limit(1).first();
if (oldSession == null) {
final Session session = new Session(userId, jwt);
sessionsCollection.insertOne(session);
}
return true;
Hope this helps
1 Like
It works, thanks:+1:
1 Like