add permissions to users

This commit is contained in:
mbecker20
2022-03-13 22:04:34 -07:00
parent 9442dacacc
commit eba85c3c11
5 changed files with 16 additions and 10 deletions
+4 -1
View File
@@ -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 }
+2 -1
View File
@@ -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
View File
@@ -17,4 +17,4 @@ app.listen(PORT, (err, address) => {
process.exit(1);
}
console.log(`monitor core listening at ${address}`);
});
});
+2 -1
View File
@@ -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",
+7 -6
View File
@@ -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;
};