Crossplatform check right.

This commit is contained in:
Quentin DECAUNES 2019-03-11 12:58:24 +01:00
parent da100e210a
commit 235b7e77d5

View File

@ -66,6 +66,15 @@ function registerRepeaterForAllInput() {
* Will display a warning if not.
*/
function checkForAdminRights() {
if (require('os').platform !== 'win32') {
const isRoot = process.getuid && process.getuid() === 0;
if (!isRoot) {
notification('danger',
`Warning: you must launch this app as administrator.<br/>`
+ `Use "sudo ryzencontroller" from terminal to fix this.`
);
}
} else {
var exec = require('child_process').exec;
exec('NET SESSION', function(err,so,se) {
if (se.length !== 0) {
@ -76,6 +85,7 @@ function checkForAdminRights() {
}
});
}
}
/**
* Will display a notification in ".notification-zone".