mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-05 08:00:48 +00:00
add permissions to users
This commit is contained in:
@@ -14,7 +14,10 @@ const local = fp((app: FastifyInstance, _: {}, done: () => void) => {
|
||||
const password = (req.body as User).password!;
|
||||
const hashedPass = await hash(password, PASSWORD_SALT_ROUNDS);
|
||||
try {
|
||||
const user = await app.users.create({ username, password: hashedPass });
|
||||
const user = await app.users.create({
|
||||
username,
|
||||
password: hashedPass,
|
||||
});
|
||||
const jwt = app.jwt.sign(
|
||||
{ id: user._id.toString() },
|
||||
{ expiresIn: TOKEN_EXPIRES_IN }
|
||||
|
||||
@@ -4,7 +4,8 @@ import { Schema } from "mongoose";
|
||||
|
||||
const users = fp((app: FastifyInstance, _: {}, done: () => void) => {
|
||||
const schema = new Schema({
|
||||
username: { type: String, index: true },
|
||||
username: { type: String, index: true, required: true },
|
||||
permissions: { type: Number, default: 0 },
|
||||
password: String,
|
||||
avatar: String,
|
||||
githubID: { type: Number, index: true },
|
||||
|
||||
+1
-1
@@ -17,4 +17,4 @@ app.listen(PORT, (err, address) => {
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`monitor core listening at ${address}`);
|
||||
});
|
||||
});
|
||||
@@ -9,7 +9,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/dockerode": "^3.3.3",
|
||||
"typescript": "^4.6.2"
|
||||
"typescript": "^4.6.2",
|
||||
"@monitor/types": "1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"dockerode": "^3.3.1",
|
||||
|
||||
Vendored
+7
-6
@@ -1,7 +1,8 @@
|
||||
export type User = {
|
||||
_id: string;
|
||||
username: string;
|
||||
password?: string;
|
||||
githubID?: string;
|
||||
avatar?: string;
|
||||
}
|
||||
_id: string;
|
||||
username: string;
|
||||
permissions: number;
|
||||
password?: string;
|
||||
githubID?: string;
|
||||
avatar?: string;
|
||||
};
|
||||
Reference in New Issue
Block a user