1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-13 17:00:06 +00:00

feat: replace ID with UID

BREAKING CHANGE: remove auto incremental ids from user, group and permissions and add a virtual uid property that returns string value of documents object id
This commit is contained in:
2023-05-09 15:01:56 +05:00
parent d2239f75c2
commit 093fe90589
36 changed files with 461 additions and 483 deletions

View File

@@ -76,7 +76,7 @@ const authenticateToken = async (
const { MODE } = process.env
if (MODE === ModeType.Desktop) {
req.user = {
userId: 1234,
userId: '1234',
clientId: 'desktopModeClientId',
username: 'desktopModeUsername',
displayName: 'desktopModeDisplayName',

View File

@@ -18,7 +18,7 @@ export const authorize: RequestHandler = async (req, res, next) => {
// no need to check for permissions when route is Public
if (await isPublicRoute(req)) return next()
const dbUser = await User.findOne({ id: user.userId })
const dbUser = await User.findOne({ _id: user.userId })
if (!dbUser) return res.sendStatus(401)
const path = getPath(req)

View File

@@ -28,7 +28,7 @@ export const desktopRestrict: RequestHandler = (req, res, next) => {
}
export const desktopUser: RequestUser = {
userId: 12345,
userId: '12345',
clientId: 'desktop_app',
username: userInfo().username,
displayName: userInfo().username,

View File

@@ -9,7 +9,7 @@ export const verifyAdminIfNeeded: RequestHandler = (req, res, next) => {
let adminAccountRequired: boolean = true
if (req.params.userId) {
adminAccountRequired = user?.userId !== parseInt(req.params.userId)
adminAccountRequired = user?.userId !== req.params.userId
} else if (req.params.username) {
adminAccountRequired = user?.username !== req.params.username
}