Spaces:
Paused
Paused
Update database.js
Browse files- database.js +9 -0
database.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
const mongoose = require('mongoose');
|
2 |
const logger = require('./logger');
|
|
|
3 |
|
4 |
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/stremio-manager';
|
5 |
|
@@ -49,6 +50,14 @@ const userSchema = new mongoose.Schema({
|
|
49 |
managedBy: { type: String, required: true }
|
50 |
});
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
const addonSchema = new mongoose.Schema({
|
53 |
transportUrl: { type: String, required: true },
|
54 |
transportName: { type: String, default: 'http' },
|
|
|
1 |
const mongoose = require('mongoose');
|
2 |
const logger = require('./logger');
|
3 |
+
const bcrypt = require('bcrypt');
|
4 |
|
5 |
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/stremio-manager';
|
6 |
|
|
|
50 |
managedBy: { type: String, required: true }
|
51 |
});
|
52 |
|
53 |
+
// Hash the password before saving it
|
54 |
+
userSchema.pre('save', async function(next) {
|
55 |
+
if (this.isModified('password')) {
|
56 |
+
this.password = await bcrypt.hash(this.password, 10);
|
57 |
+
}
|
58 |
+
next();
|
59 |
+
});
|
60 |
+
|
61 |
const addonSchema = new mongoose.Schema({
|
62 |
transportUrl: { type: String, required: true },
|
63 |
transportName: { type: String, default: 'http' },
|