From a2c94d68f9725210cb77e30e4a1eccaa4972528b Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Tue, 13 Feb 2018 15:10:33 +0100
Subject: [PATCH] request an account uses default content from congfiguration

---
 .../model/user/ConfigurationElementType.java       |  2 +-
 web/src/main/webapp/login.xhtml                    | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/model/src/main/java/lcsb/mapviewer/model/user/ConfigurationElementType.java b/model/src/main/java/lcsb/mapviewer/model/user/ConfigurationElementType.java
index e4577f3ccb..5c8ca43e5c 100644
--- a/model/src/main/java/lcsb/mapviewer/model/user/ConfigurationElementType.java
+++ b/model/src/main/java/lcsb/mapviewer/model/user/ConfigurationElementType.java
@@ -150,7 +150,7 @@ public enum ConfigurationElementType {
    * Default content of the email when requesting for an account in the system.
    */
   REQUEST_ACCOUNT_DEFAULT_CONTENT("Email content used for requesting an account",
-      "Dear Diseas map team,\nI would like to request for an account.\nKind regards", ConfigurationElementEditType.TEXT,
+      "Dear Disease map team,\nI would like to request an account in the system.\nKind regards", ConfigurationElementEditType.TEXT,
       false),
 
   ;
diff --git a/web/src/main/webapp/login.xhtml b/web/src/main/webapp/login.xhtml
index 0f59d45952..d2464a754b 100644
--- a/web/src/main/webapp/login.xhtml
+++ b/web/src/main/webapp/login.xhtml
@@ -72,6 +72,18 @@
                 }
             });
         }
+        function requestAccount() {
+        	var email, content; 
+        	return minerva.ServerConnector.getConfigurationParam("REQUEST_ACCOUNT_EMAIL").then(function(result){
+        		email = result;
+            return minerva.ServerConnector.getConfigurationParam("REQUEST_ACCOUNT_DEFAULT_CONTENT");
+        	}).then(function(result){
+        		content = encodeURIComponent(result);
+        		url = 'mailto:'+email+'?subject=MINERVA account request&body='+content;
+            window.location.href=url; 
+          })
+        	return false;
+        }
 
         //]]>
     </script>
@@ -108,7 +120,7 @@
             <br/>
 
             <a href="javascript:;" id="register_button"
-               onClick="window.location.href='mailto:#{userMB.requestAccountEmail}?subject=MINERVA account request'; return false;"
+               onClick="requestAccount(); return false"
                class="adminLink"><i class="fa fa-chevron-right"></i> REQUEST AN ACCOUNT</a>
 
         </h:form>
-- 
GitLab