@heyhru/business-auth-user
v0.13.1
Published
Auth user domain logic: service, model, sql (Feishu binding)
Downloads
349
Readme
@heyhru/business-auth-user
Auth user domain logic: service, model, sql. Provides user CRUD plus Feishu binding helpers for any app that wants the same auth model as DMS (username + scrypt-hashed password + optional Feishu open_id/union_id).
The schema (e.g. role enum, table name) is not owned by this package — each app declares its own migration. This package only ships the SQL operations and assumes a users table that conforms to the expected shape.
API
getUserByUsername(username: string)
Look up a user by username. Returns the full user row (including password_hash) or undefined.
Used by auth service for login and password change.
updateUserPassword(id: string, hash: string)
Update the password_hash for a user by ID.
Route handlers (Fastify)
The following functions are route-facing handlers with signature (req: FastifyRequest, reply: FastifyReply). Register them directly on a Fastify instance.
| Function | Route action | Description |
| ------------ | -------------------- | -------------------------------- |
| userList | POST /users/list | List all users |
| userGet | POST /users/get | Get a user by id in body |
| userCreate | POST /users/create | Create a user, hashes password |
| userUpdate | POST /users/update | Update email or role by id |
| userDelete | POST /users/delete | Delete a user by id |
