1 parent
a3b3fbe269
commit
2a0eda5c34
2 files changed
+41
-13
No files matched your search
@@ -54,11 +54,12 @@ $(function() {
|
||||
});
|
||||
|
||||
self.editorPasswordMismatch = ko.pureComputed(function() {
|
||||
return self.editorPassword() != self.editorRepeatedPassword();
|
||||
return self.editorPassword() !== self.editorRepeatedPassword();
|
||||
});
|
||||
|
||||
self.requestData = function() {
|
||||
if (!CONFIG_ACCESS_CONTROL) return;
|
||||
if (!loginState.isAdmin()) return;
|
||||
|
||||
OctoPrint.users.list()
|
||||
.done(self.fromResponse);
|
||||
@@ -97,8 +98,20 @@ $(function() {
|
||||
self.showEditUserDialog = function(user) {
|
||||
if (!CONFIG_ACCESS_CONTROL) return;
|
||||
|
||||
self.currentUser(user);
|
||||
self.editUserDialog.modal("show");
|
||||
var process = function(user) {
|
||||
self.currentUser(user);
|
||||
self.editUserDialog.modal("show");
|
||||
};
|
||||
|
||||
// make sure we have the current user data, see #2534
|
||||
OctoPrint.users.get(user.name)
|
||||
.done(function(data) {
|
||||
process(data);
|
||||
})
|
||||
.fail(function() {
|
||||
log.warn("Could not fetch current user data, proceeding with client side data copy");
|
||||
process(user);
|
||||
});
|
||||
};
|
||||
|
||||
self.confirmEditUser = function() {
|
||||
@@ -175,6 +188,7 @@ $(function() {
|
||||
if (!user) {
|
||||
throw OctoPrint.InvalidArgumentError("user must be set");
|
||||
}
|
||||
if (!loginState.isAdmin()) return $.Deferred().reject("You are not authorized to perform this action").promise();
|
||||
|
||||
return OctoPrint.users.add(user)
|
||||
.done(self.fromResponse);
|
||||
@@ -184,8 +198,9 @@ $(function() {
|
||||
if (!user) {
|
||||
throw OctoPrint.InvalidArgumentError("user must be set");
|
||||
}
|
||||
if (!loginState.isAdmin()) return $.Deferred().reject("You are not authorized to perform this action").promise();
|
||||
|
||||
if (user.name == self.loginState.username()) {
|
||||
if (user.name === self.loginState.username()) {
|
||||
// we do not allow to delete ourselves
|
||||
new PNotify({
|
||||
title: gettext("Not possible"),
|
||||
@@ -213,7 +228,10 @@ $(function() {
|
||||
};
|
||||
|
||||
self.generateApikey = function(username) {
|
||||
return OctoPrint.users.generateApiKey(username);
|
||||
return OctoPrint.users.generateApiKey(username)
|
||||
.done(function() {
|
||||
self.requestData();
|
||||
});
|
||||
};
|
||||
|
||||
self.deleteApikey = function(username) {
|
||||
@@ -221,9 +239,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.onUserLoggedIn = function(user) {
|
||||
if (user.admin) {
|
||||
self.requestData();
|
||||
}
|
||||
self.requestData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ $(function() {
|
||||
self.access_apikey(undefined);
|
||||
self.interface_language("_default");
|
||||
|
||||
if (newUser != undefined) {
|
||||
if (newUser !== undefined) {
|
||||
self.access_apikey(newUser.apikey);
|
||||
if (newUser.settings.hasOwnProperty("interface") && newUser.settings.interface.hasOwnProperty("language")) {
|
||||
self.interface_language(newUser.settings.interface.language);
|
||||
@@ -34,18 +34,30 @@ $(function() {
|
||||
});
|
||||
|
||||
self.passwordMismatch = ko.pureComputed(function() {
|
||||
return self.access_password() != self.access_repeatedPassword();
|
||||
return self.access_password() !== self.access_repeatedPassword();
|
||||
});
|
||||
|
||||
self.show = function(user) {
|
||||
if (!CONFIG_ACCESS_CONTROL) return;
|
||||
|
||||
if (user == undefined) {
|
||||
if (user === undefined) {
|
||||
user = self.loginState.currentUser();
|
||||
}
|
||||
|
||||
self.currentUser(user);
|
||||
self.userSettingsDialog.modal("show");
|
||||
var process = function(user) {
|
||||
self.currentUser(user);
|
||||
self.userSettingsDialog.modal("show");
|
||||
};
|
||||
|
||||
// make sure we have the current user data, see #2534
|
||||
OctoPrint.users.get(user.name)
|
||||
.done(function(data) {
|
||||
process(data);
|
||||
})
|
||||
.fail(function() {
|
||||
log.warn("Could not fetch current user data, proceeding with client side data copy");
|
||||
process(user);
|
||||
});
|
||||
};
|
||||
|
||||
self.save = function() {
|
||||
|
||||
Reference in new issue
Block a user