# AuthService.signinWithId custom logic

```ts
/* --------------------------- start custom logic --------------------------- */
if (!body.data?.user_id)
  throw new exceptions.BadRequestException("User ID required");
if (
  opt?.bypassAuthorization &&
  authData?.current?.user?.role_group !== "master"
)
  throw new exceptions.UnauthorizedException("Unauthorized");

const doc = await this.userModel.findById(body.data.user_id);
if (!doc) {
  throw new exceptions.BadRequestException("User not registered");
}

if (doc.is_deleted) throw new exceptions.BadRequestException("User deleted");

const payload: Jsm.Core.Security.JWTUserAuthPayload = {
  _id: doc._id.toString(),
  tracking_id: doc.tracking_id,
  role: doc.role,
  space: "default",
};

const authManager = new AuthManager();
const token = authManager.generateToken(
  payload,
  "default",
  false,
  config.security.jwt
);
const refresh_token = authManager.generateToken(
  payload,
  "default",
  true,
  config.security.jwt
);

result = {
  data: {
    user: mapDocumentToExposed(doc),
    token,
    refresh_token,
  },
};
/* ---------------------------- end custom logic ---------------------------- */
```
