generated from azures04/Base-REST-API
Add bans, user cache, auth routes & token changes
Introduce user bans and caching, extend schemas, and add auth/user endpoints. Adds bans DDL and banRepo plus adminService to manage bans; introduces modules/cache for in-memory user caching used by authService and userService. Updates users and credentials DDLs (role, isDisabled, shouldReset). Changes tokensService to include role in access tokens and store refresh tokens as SHA-256 hashes. Updates repos (credentials create RETURNING, usersRepo.updateProfile positional params), enhances authService with isLogged/isNotLogged middleware, ban checks, and refreshed token flow. Adds auth routes (login, logout, refresh, register) and user routes (/me).
This commit is contained in:
@@ -13,7 +13,7 @@ async function findByUserId(userId) {
|
||||
|
||||
async function create(userId, passwordHash) {
|
||||
try {
|
||||
const sql = "INSERT INTO credentials (userId, passwordHash) VALUES (?, ?)"
|
||||
const sql = "INSERT INTO credentials (userId, passwordHash) VALUES (?, ?) RETURNING *"
|
||||
const rows = await pool.query(sql, [userId, passwordHash])
|
||||
return rows || null
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user