generated from azures04/Base-REST-API
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).
14 lines
647 B
JavaScript
14 lines
647 B
JavaScript
const express = require("express")
|
|
const authService = require("../../../../services/authService")
|
|
const router = express.Router()
|
|
|
|
router.post("/", authService.isNotLogged, async (req, res) => {
|
|
if (process.env.REGISTER_ENABLED != "true") {
|
|
return res.status(401).json({ error: "registration_disabled", error_description: "The administrator has disabled internal registration." })
|
|
}
|
|
const { identifier, password, avatarURL, displayName } = req.body
|
|
const user = await authService.registerLocal({ identifier, password, profile: { avatarURL, displayName } })
|
|
return res.status(201).json(user)
|
|
})
|
|
|
|
module.exports = router |