Skip to content
Snippets Groups Projects
Commit fbcae4e0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when there is no email account connected to request an account link then...

when there is no email account connected to request an account link then request an account link is disabled
parent 4bec58cb
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!565Resolve "Add option to disable `REQUEST AN ACCOUNT`"
Pipeline #8108 passed
......@@ -654,9 +654,10 @@ function createFooter() {
/**
*
* @returns {HTMLElement}
* @param {Configuration} configuration
* @return {HTMLElement}
*/
function createLoginDiv() {
function createLoginDiv(configuration) {
var loggedIn = false;
var result = functions.createElement({type: "center"});
......@@ -707,11 +708,17 @@ function createLoginDiv() {
$("#go_to_map_button", resultDiv).hide();
resultDiv.appendChild(functions.createElement({type: "br"}));
var requestAccountStyle = "";
if (configuration.getOption(ConfigurationType.REQUEST_ACCOUNT_EMAIL).getValue() === "" ||
configuration.getOption(ConfigurationType.REQUEST_ACCOUNT_EMAIL).getValue() === undefined) {
requestAccountStyle = "display: none";
}
resultDiv.appendChild(functions.createElement({
type: "a",
href: "javascript:;",
id: "register_button",
className: "adminLink",
style: requestAccountStyle,
content: '<i class="fa fa-chevron-right"></i> REQUEST AN ACCOUNT</a>',
xss: false
}));
......@@ -757,9 +764,9 @@ function createLoginDiv() {
});
$('#register_button', result).click(function () {
var email, content;
return ServerConnector.getConfigurationParam("REQUEST_ACCOUNT_EMAIL").then(function (result) {
return ServerConnector.getConfigurationParam(ConfigurationType.REQUEST_ACCOUNT_EMAIL).then(function (result) {
email = result;
return ServerConnector.getConfigurationParam("REQUEST_ACCOUNT_DEFAULT_CONTENT");
return ServerConnector.getConfigurationParam(ConfigurationType.REQUEST_ACCOUNT_DEFAULT_CONTENT);
}).then(function (result) {
content = encodeURIComponent(result);
document.location.href = 'mailto:' + email + '?subject=MINERVA account request&body=' + content;
......@@ -783,8 +790,8 @@ function createLogin(params) {
// make sure that we are logged in
return ServerConnector.createSession().then(function () {
return ServerConnector.getConfiguration();
}).then(function () {
var loginDiv = createLoginDiv();
}).then(function (configuration) {
var loginDiv = createLoginDiv(configuration);
params.getElement().appendChild(loginDiv);
return createFooter();
}).then(function (footer) {
......
......@@ -5,6 +5,7 @@ require("./mocha-config");
var Promise = require("bluebird");
var minerva = require('../../main/js/minerva');
var ConfigurationType = require('../../main/js/ConfigurationType');
var SecurityError = require('../../main/js/SecurityError');
var ServerConnectorMock = require('./ServerConnector-mock');
var Point = require('../../main/js/map/canvas/Point');
......@@ -279,8 +280,15 @@ describe('minerva global', function () {
});
});
describe('createLogin', function () {
it('no request account email configured', function () {
helper.getConfiguration().getOption(ConfigurationType.REQUEST_ACCOUNT_EMAIL).setValue("");
return minerva.createLogin({element: testDiv}).then(function () {
assert.ok($("#register_button").css("display") === "none");
});
});
it('default', function () {
return minerva.createLogin({element: testDiv}).then(function () {
assert.ok($("#register_button").css("display") !== "none");
assert.ok(testDiv.innerHTML.indexOf("MiNERVA") >= 0);
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment