generated from azures04/Base-REST-API
Add auth, JWT tokens, and bootstrap startup
Introduce bootstrap entrypoint and prestartup to ping DB and generate/manage RSA keypair. Add security module for key IO. Implement JWT-based access and refresh tokens (tokensService) with refresh_tokens table and repo. Add auth, provider and user services, and refresh-token management. Update repositories (users, credentials, providers, servers) with SQL fixes and new helper methods. Move DDL execution to bootstrap (remove from server). Update package.json main and add dependencies (bcryptjs, jsonwebtoken). Update .env.example and .gitignore accordingly.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const userRepo = require("../repositories/usersRepo")
|
||||
|
||||
async function getProfile({ userId }) {
|
||||
return await userRepo.findById(userId)
|
||||
}
|
||||
|
||||
async function updateProfile({ userId, profile = { displayName, avatarURL } }) {
|
||||
return await userRepo.updateProfile(userId, profile.displayName, profile.avatarURL)
|
||||
}
|
||||
|
||||
async function deleteAccount({ userId }) {
|
||||
return await userRepo.remove(userId)
|
||||
}
|
||||
|
||||
async function isLocal({ userId }) {
|
||||
return await userRepo.isLocal(userId)
|
||||
}
|
||||
|
||||
async function createUser({ identifier, serverId, remoteId = null, profile = { displayName, avatarUrl } }) {
|
||||
return await userRepo.create(identifier, serverId, remoteId, profile.displayName, profile.avatarUrl)
|
||||
}
|
||||
|
||||
async function getShadowUser({ serverId, remoteId }) {
|
||||
return await userRepo.findByServerAndRemoteId(serverId, remoteId)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isLocal,
|
||||
getProfile,
|
||||
createUser,
|
||||
updateProfile,
|
||||
deleteAccount,
|
||||
getShadowUser
|
||||
}
|
||||
Reference in New Issue
Block a user