Skip to content

AUTH - update return for /register and /login #50

@codastream

Description

@codastream

Description

user story : AS A Developer, I WANT the Authentication service to return structured user data objects upon registration and login SO THAT the frontend can immediately synchronize the application state and user interface without making an additional API call.

Details

It will be used by frontend.

Alongside #49 , it would help if auth service could return the same detailed object (without password) :

for instance for /register

return reply.code(201).send({
  data: {
    authId: id,
    username: username,
    email: email,
    role: 'USER' // default
  },
  message: 'User registered successfully'
});

and login

reply
  .setCookie('token', token, getCookieOptions(AUTH_CONFIG.COOKIE_MAX_AGE_SECONDS))
  .code(200)
  .send({
    data: {
      authId: user.id,
      username: user.username,
      email: user.email,
      role: user.role,
    },
    message: `Welcome ${user.username} !`
  });

Priority

high

Definition of done

  • Zod validation : use or update the auth.schema in core package ?

Out of scope

Subtasks

  • Tests
  • Implementation
  • Doc in wiki + Swagger ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions