Commit 9902ffef authored by Curtis Adam's avatar Curtis Adam

Rework admin id configuration

parent 50e4387e
...@@ -17,7 +17,7 @@ arsnova🍅cards uses Meteor as application framework. Download and install [Met ...@@ -17,7 +17,7 @@ arsnova🍅cards uses Meteor as application framework. Download and install [Met
4. Install the npm package dependencies inside the local repository **"cards folder"** `meteor npm install` 4. Install the npm package dependencies inside the local repository **"cards folder"** `meteor npm install`
### Settings (These steps are only required if you want to deploy 🍅cards on a server) ### Settings (These steps are only required if you want to deploy 🍅cards on a server)
1. Set your initial admin user in `settings.json` (cas account) 1. Add the cas id of the admins inside the admin.id array of `settings.json` (cas account)
2. Change `settings.json` according to your needs 2. Change `settings.json` according to your needs
> Warning: Never publish your settings file! > Warning: Never publish your settings file!
......
...@@ -141,20 +141,11 @@ Meteor.users.after.insert(function (userId, doc) { ...@@ -141,20 +141,11 @@ Meteor.users.after.insert(function (userId, doc) {
} }
}); });
if (doc.services !== undefined && doc.services.cas !== undefined) { if (doc.services !== undefined && doc.services.cas !== undefined) {
if (doc.services.cas.id === Meteor.settings.admin.name) { Roles.addUsersToRoles(doc._id, [
Roles.addUsersToRoles(doc._id, [ 'standard',
'standard', 'university',
'university', 'firstLogin'
'admin', ]);
'firstLogin'
]);
} else {
Roles.addUsersToRoles(doc._id, [
'standard',
'university',
'firstLogin'
]);
}
} else { } else {
Roles.addUsersToRoles(doc._id, ['standard', 'firstLogin']); Roles.addUsersToRoles(doc._id, ['standard', 'firstLogin']);
} }
......
...@@ -257,6 +257,11 @@ const casValidate = (req, ticket, token, service, callback) => { ...@@ -257,6 +257,11 @@ const casValidate = (req, ticket, token, service, callback) => {
const userId = Accounts.insertUserDoc({}, options); const userId = Accounts.insertUserDoc({}, options);
user = Meteor.users.findOne(userId); user = Meteor.users.findOne(userId);
} }
if (Meteor.settings.admin.id.includes(options.services.cas.id)) {
Roles.addUsersToRoles(user._id, ['admin']);
} else {
Roles.removeUsersFromRoles(user._id, ['admin']);
}
if (attrs.debug) { if (attrs.debug) {
console.log(`Using user account ${JSON.stringify(user)}`); console.log(`Using user account ${JSON.stringify(user)}`);
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
"FCM_API_KEY": "AAAAIST6Cb4:APA91bEazKYwihnbcAyqMaX_oNZvNlzoplnCKXpVtBKx-HfGqh9Oof9zufvxvcsINOxIs1guu9cUtXC1YGWFNIAJEDJN_vnc5xMqg1koTJd5bZ5jux3q2Qnstu4kiB_WrbehSPswvw_hIB-q-QNTmH0bVT1YTAXD3A" "FCM_API_KEY": "AAAAIST6Cb4:APA91bEazKYwihnbcAyqMaX_oNZvNlzoplnCKXpVtBKx-HfGqh9Oof9zufvxvcsINOxIs1guu9cUtXC1YGWFNIAJEDJN_vnc5xMqg1koTJd5bZ5jux3q2Qnstu4kiB_WrbehSPswvw_hIB-q-QNTmH0bVT1YTAXD3A"
}, },
"admin": { "admin": {
"name": "hg13345" "id": []
}, },
"facebook": { "facebook": {
"api": "162760697401847", "api": "162760697401847",
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"BT_PRIVATE_KEY": "b508f71a0e0b01940b0fbe75940debb9" "BT_PRIVATE_KEY": "b508f71a0e0b01940b0fbe75940debb9"
}, },
"admin": { "admin": {
"name": "hg13345" "id": []
}, },
"facebook": { "facebook": {
"api": "162760697401847", "api": "162760697401847",
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"BT_PRIVATE_KEY": "b508f71a0e0b01940b0fbe75940debb9" "BT_PRIVATE_KEY": "b508f71a0e0b01940b0fbe75940debb9"
}, },
"admin": { "admin": {
"name": "hg13345" "id": []
}, },
"facebook": { "facebook": {
"api": "162760697401847", "api": "162760697401847",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment