diff --git a/CHANGELOG b/CHANGELOG index ee5360ff151a257f66920f37480c01d56ff7268d..c376c44034b9b9c2d82cdaa8db14beab21bc6521 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ minerva (14.0.0~beta.0) unstable; urgency=low * Small improvement: sorting by columns that doesn't make sense in admin panel is disabled (#895) + * Small improvement: version of minerva is visible in map browser panel * Bug fix: work on FF Private Window mode could cause logout or raise an error on when opening new tab with minerva (#892) * Bug fix: fetching list of miRnas resulted sometimes in "Internal Server @@ -25,6 +26,7 @@ minerva (14.0.0~beta.0) unstable; urgency=low * Bug fix: user with modify access to the project can edit it in admin panel (#901) * Bug fix: creating project with too long name hung (#916) + * Bug fix: too long user login thrown an error (#915) -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 21 Aug 2019 21:00:00 +0200 diff --git a/frontend-js/src/main/js/gui/admin/EditUserDialog.js b/frontend-js/src/main/js/gui/admin/EditUserDialog.js index fad069c7d2d1475056ab68ed8b92e93d3a3185d5..7ee1ad496541995f2089f403a097e9b5f619fee1 100644 --- a/frontend-js/src/main/js/gui/admin/EditUserDialog.js +++ b/frontend-js/src/main/js/gui/admin/EditUserDialog.js @@ -670,10 +670,19 @@ EditUserDialog.prototype.checkValidity = function () { error += "<li>Password doesn't match</li>"; isValid = false; } + if (self.getIsNewUser() && self.getPassword() === "") { + error += "<li>Password for the user is not defined</li>"; + isValid = false; + } + if (self.getLogin() === "" || self.getLogin() === undefined) { error += "<li>Login must not be empty</li>"; isValid = false; } + if (self.getLogin().length > 255) { + error += "<li>Login must be shorter than 256 characters</li>"; + isValid = false; + } if (isValid) { return Promise.resolve(true); } else { @@ -708,6 +717,10 @@ EditUserDialog.prototype.getLogin = function () { return $("[name='userLogin']", self.getElement()).val(); }; +EditUserDialog.prototype.setLogin = function (login) { + $("[name='userLogin']", this.getElement()).val(login); +}; + /** * * @returns {string} diff --git a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js index 1fbd8f5249fa43c8aa665698a75dc29b6b1c7522..61de9eb2110c72004f97ea94e1a82377c7a7a78c 100644 --- a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js @@ -91,8 +91,7 @@ LeftPanel.prototype._createPanelGui = function () { type: "div", className: "minerva-logo-footer", content: "<a href='https://minerva.pages.uni.lu/doc/' target='_blank'>" + - "<div class='minerva-pages-logo'></div> Powered by MINERVA Platform" + - "</a>", + "<div class='minerva-pages-logo'></div> Powered by MINERVA Platform (v" + self.getConfiguration().getVersion() + ")</a>", xss: false })); }; diff --git a/frontend-js/src/test/js/gui/admin/EditUserDialog-test.js b/frontend-js/src/test/js/gui/admin/EditUserDialog-test.js index d6eeb71c49494849b3aceb1db69566e5fdb160ed..fffbc379b3ca5fb7150114c9b6bf6f9d59f24672 100644 --- a/frontend-js/src/test/js/gui/admin/EditUserDialog-test.js +++ b/frontend-js/src/test/js/gui/admin/EditUserDialog-test.js @@ -10,15 +10,18 @@ var ServerConnector = require('../../ServerConnector-mock'); var logger = require('../../logger'); -var Promise = require('bluebird'); var chai = require('chai'); var assert = chai.assert; var expect = chai.expect; -function createEditUserDialog(project, user) { +/** + * + * @param {User} user + * @return {EditUserDialog} + */ +function createEditUserDialog(user) { return new EditUserDialog({ element: testDiv, - project: project, user: user, configuration: helper.getConfiguration(), serverConnector: ServerConnector @@ -29,14 +32,10 @@ describe('EditUserDialog', function () { describe('init', function () { it('empty user', function () { - var dialog; - var project; var user = new User({}); - return ServerConnector.getProject().then(function (result) { - project = result; - dialog = createEditUserDialog(project, user); - return dialog.init(); - }).then(function () { + var dialog = createEditUserDialog(user); + + return dialog.init().then(function () { assert.equal(0, logger.getWarnings().length); assert.ok(testDiv.innerHTML.indexOf("DEFAULT PRIVILEGE FOR NEW PROJECT") >= 0); assert.equal(testDiv.innerHTML.indexOf("DEFAULT PRIVILEGE FOR NEW PROJECT"), testDiv.innerHTML.lastIndexOf("DEFAULT PRIVILEGE FOR NEW PROJECT")); @@ -47,14 +46,26 @@ describe('EditUserDialog', function () { describe('checkValidity', function () { it('empty user', function () { - var dialog; - var project; var user = new User({}); - return ServerConnector.getProject().then(function (result) { - project = result; - dialog = createEditUserDialog(project, user); - return dialog.init(); + var dialog = createEditUserDialog(user); + + return dialog.init().then(function () { + return dialog.checkValidity().then(function () { + assert.ok(null); + }, function (error) { + assert.ok(error instanceof ValidationError); + }); }).then(function () { + dialog.destroy(); + }); + }); + + it('new user without password', function () { + var user = new User({}); + var dialog = createEditUserDialog(user); + + return dialog.init().then(function () { + dialog.setLogin("x"); return dialog.checkValidity().then(function () { assert.ok(null); }, function (error) { @@ -65,16 +76,28 @@ describe('EditUserDialog', function () { }); }); + it('too long user login', function () { + var dialog; + var user = new User({}); + dialog = createEditUserDialog(user); + return dialog.init().then(function () { + dialog.setLogin("x".repeat(256)); + return dialog.checkValidity().then(function () { + assert.ok(null); + }).catch(function (error) { + assert.ok(error instanceof ValidationError); + }); + }).then(function () { + dialog.destroy(); + }); + }); + it('existing user', function () { var dialog; - var project; var user; return ServerConnector.getUser("anonymous").then(function (result) { user = result; - return ServerConnector.getProject(); - }).then(function (result) { - project = result; - dialog = createEditUserDialog(project, user); + dialog = createEditUserDialog(user); return dialog.init(); }).then(function () { return dialog.checkValidity(); @@ -90,14 +113,10 @@ describe('EditUserDialog', function () { it('existing user', function () { helper.loginAsAdmin(); var dialog; - var project; var user; return ServerConnector.getUser("admin").then(function (result) { user = result; - return ServerConnector.getProject(); - }).then(function (result) { - project = result; - dialog = createEditUserDialog(project, user); + dialog = createEditUserDialog(user); return dialog.init(); }).then(function () { return dialog.onSaveClicked(); @@ -111,16 +130,12 @@ describe('EditUserDialog', function () { it('existing user', function () { helper.loginAsAdmin(); var dialog; - var project; var user; var serializedPrivileges; return ServerConnector.getUser("anonymous").then(function (result) { user = result; serializedPrivileges = user.getPrivileges().slice(); - return ServerConnector.getProject(); - }).then(function (result) { - project = result; - dialog = createEditUserDialog(project, user); + dialog = createEditUserDialog(user); return dialog.init(); }).then(function () { var checkbox = $("[name=privilege-checkbox]", dialog.getElement())[0];