Files
Server/routes/api/v1/user/me.js
T
azures04 38882d7b87 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).
2026-09-16 01:45:44 +02:00

22 lines
797 B
JavaScript

const express = require("express")
const userService = require("../../../../services/userService")
const router = express.Router()
router.get("/", async (req, res) => {
const user = await userService.getProfile({ userId: req.user.id })
return res.status(200).json(user)
})
router.patch("/avatar", async (req, res) => {
const { avatarURL } = req.body
const updatedProfile = await userService.updateProfile({ userId: req.user.id, profile: { avatarURL } })
return res.status(200).json(updatedProfile)
})
router.patch("/displayname", async (req, res) => {
const { displayName } = req.body
const updatedProfile = await userService.updateProfile({ userId: req.user.id, profile: { displayName } })
return res.status(200).json(updatedProfile)
})
module.exports = router