Login fail in user-management

I can’t seem to make it right, i followed the guideline and implement the

  • getUser
  • addUser
  • loginUser
  • logoutUser
  • getUserSession

I passed 3 test except for the login.

Hey @learner1283

Just FYI posting answer code is against forum guidelines. I would suggest you remove it.
However, have you done everything the lab said?

There are more funcitons you have to implement.

Task
For this Ticket, you’ll be required to implement all the methods in usersDAO.js that are called by the API endpoints in users.controller.js. Specifically, you’ll implement:

  • getUser
  • addUser
  • loginUser
  • logoutUser
  • getUserSession

Hope this helps :slight_smile:

@natac13 Yes i implemented them all, i passed 3 test except for the login.

From what I remember of the error, I would check your implementation of getUserSessions() I know it is the login test which is failing but I believe the error was showing at the part below, correct me if I am wrong.

test("it allows a user to login", async () => {
    const actual = await UsersDAO.loginUser(testUser.email, sessionUser.jwt)
    expect(actual.success).toBeTruthy()

    const sessionResult = await UsersDAO.getUserSession(testUser.email)
    delete sessionResult._id // **** Was the Error here?

    expect(sessionResult).toEqual(sessionUser)
  })
1 Like

Yeah i think that’s where the error is, the getUserSession’s parameter is email so i just used it inside the findOne function as a value to email instead of the user_id… I got it, Thanks!

1 Like

That was my error too!

Hi @Herbertvargas,

Did the unit test pass? If yes, check the console log for information. If not, check the test case and look for any error message.

Kanika

Sorry, I meant that It was the same error but I corrected it properly.

Thank you

1 Like