Added UI flow for creating default admin account. Dialog will show up after enabling or in the login menu if the admin account isn't present

This commit is contained in:
Tzahi12345
2020-04-30 16:31:36 -04:00
parent e5f9694da0
commit e7b841c056
11 changed files with 163 additions and 2 deletions

View File

@@ -96,7 +96,8 @@ exports.registerUser = function(req, res) {
video: []
},
subscriptions: [],
created: Date.now()
created: Date.now(),
role: userid === 'admin' ? 'admin' : 'user'
};
// check if user exists
if (users_db.get('users').find({uid: userid}).value()) {
@@ -238,6 +239,23 @@ exports.ensureAuthenticatedElseError = function(req, res, next) {
}
}
// change password
exports.changeUserPassword = async function(user_uid, new_pass) {
return new Promise(resolve => {
bcrypt.hash(new_pass, saltRounds)
.then(function(hash) {
users_db.get('users').find({uid: user_uid}).assign({passhash: hash}).write();
resolve(true);
}).catch(err => {
resolve(false);
});
});
}
exports.adminExists = function() {
return !!users_db.get('users').find({uid: 'admin'}).value();
}
// video stuff
exports.getUserVideos = function(user_uid, type) {