@saulo.martins/backend-auth
v1.0.5
Published
NestJS JWT auth module: signup/login, `/auth/me` profile, password reset, change password.
Downloads
345
Readme
@saulo.martins/backend-auth
NestJS JWT auth module: signup/login, /auth/me profile, password reset, change password.
Signup: userType and host responsibilities
When the client sends userType: "customer" or "company" on POST /auth/signup, this package only creates the User row. You must implement AuthUsersServiceContract.onSignupComplete in your app to create domain-specific rows.
Typical pattern (photo.app / Supabase):
| userType | Suggested host behaviour |
|------------|---------------------------|
| customer | Insert/link your customer profile (e.g. CustomerUser). |
| company | Create Company, then CompanyMember with role: "owner" linking userId to companyId. Use SignupFollowUpPayload.companyDisplayName as the default company name, or your own fallback if it is empty. |
The payload includes companyDisplayName: firstName + lastName trimmed when userType === "company" (same idea as joining names for createCompanyWithOwner in the app).
Also implement getProfileRoles so /auth/me can set isCustomer / isCompany. isAdmin is derived from ADMIN_EMAILS (comma-separated emails).
Environment
ADMIN_EMAILS: optional; listed emails getisAdmin: trueon/auth/me.
