Commit 02c35fe1 authored by Piotr Gawron's avatar Piotr Gawron

login page doesn't contain back to map if guest account doesn't have access

parent b59a2c90
Pipeline #8103 passed with stage
in 11 minutes and 7 seconds
......@@ -22,6 +22,7 @@ var SelectionContextMenu = require('./gui/SelectionContextMenu');
var GuiConnector = require('./GuiConnector');
var ServerConnector = require('./ServerConnector');
var SecurityError = require('./SecurityError');
var MolArt = require('./map/structure/MolArt');
......@@ -703,6 +704,8 @@ function createLoginDiv() {
content: '<i class="fa fa-chevron-right"></i> BACK TO MAP',
xss: false
}));
$("#go_to_map_button", resultDiv).hide();
resultDiv.appendChild(functions.createElement({type: "br"}));
resultDiv.appendChild(functions.createElement({
type: "a",
......@@ -781,12 +784,21 @@ function createLogin(params) {
return ServerConnector.createSession().then(function () {
return ServerConnector.getConfiguration();
}).then(function () {
var loginDiv = createLoginDiv(params);
var loginDiv = createLoginDiv();
params.getElement().appendChild(loginDiv);
return createFooter();
}).then(function (footer) {
params.getElement().appendChild(footer);
return insertGoogleAnalyticsCode();
}).then(function () {
return ServerConnector.getProject().then(function () {
$("#go_to_map_button").show();
}).catch(function (e) {
if (e instanceof SecurityError) {
} else {
throw e;
}
})
})
}
......
......@@ -284,6 +284,17 @@ describe('minerva global', function () {
assert.ok(testDiv.innerHTML.indexOf("MiNERVA") >= 0);
});
});
it('anonymous without access to default map', function () {
var originalFunction = ServerConnectorMock.getProject;
ServerConnectorMock.getProject = function () {
return Promise.reject(new SecurityError("Access denied."));
};
return minerva.createLogin({element: testDiv}).then(function () {
assert.ok($("#go_to_map_button").css('display') === 'none');
}).finally(function () {
ServerConnectorMock.getProject = originalFunction;
});
});
});
it('getProject', function () {
return ServerConnectorMock.getProject().then(function (project) {
......
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