Finished up with toke command list in admin panel.

This commit is contained in:
rainbow napkin 2024-12-12 19:23:11 -05:00
parent 59fe38a5fe
commit 5fe1620c20
7 changed files with 132 additions and 7 deletions

View file

@ -21,6 +21,7 @@ const {mongoose} = require('mongoose');
//const {userModel} = require('./userSchema');
const userSchema = require('./userSchema');
const channelPermissionSchema = require('./channel/channelPermissionSchema');
const {errorHandler} = require('../utils/loggerUtils');
//This originally belonged to the permissionSchema, but this avoids circular dependencies.
//We could update all references but quite honestly I that would be uglier, this should have a copy too...
@ -119,8 +120,12 @@ permissionSchema.statics.rankToNum = function(rank){
}
permissionSchema.statics.permCheck = async function(user, perm){
const userDB = await userSchema.userModel.findOne({user: user.user});
return await this.permCheckByUserDoc(userDB, perm);
if(user != null){
const userDB = await userSchema.userModel.findOne({user: user.user});
return await this.permCheckByUserDoc(userDB, perm);
}else{
return await this.permCheckByUserDoc(null, perm);
}
}
permissionSchema.statics.permCheckByUserDoc = async function(user, perm){

View file

@ -28,6 +28,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.-->
<%- include('partial/adminPanel/userList', {user, userList, rankEnum}) %>
<%- include('partial/adminPanel/permList', {permList, rankEnum}) %>
<%- include('partial/adminPanel/userBanList') %>
<%- include('partial/adminPanel/tokeCommandList') %>
</div>
</body>
<footer>

View file

@ -13,6 +13,12 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.-->
<div id="admin-channel-list-div" class="admin-list-div">
<div id="toke-command-list-div" class="admin-list-div">
<h3>Toke Command List:</h3>
<div class="control-prompt">
<input placeholder="Add Command..." id="new-toke-command-input" class="control-prompt">
<button id="new-toke-command-button" class="positive-button">Add</button>
</div>
<div class="dynamic-container toke-command-list">
</div>
</div>