VIVO-333 External-auth login button should be language-sensitive.

Don't specify the text in the runtime.properties. Instead, get it from all.properties. Show the button if externalAuth.netIdHeaderName is specified.
This commit is contained in:
j2blake 2013-10-09 16:38:14 -04:00
parent 2417555e1c
commit c9248b1f81
6 changed files with 207 additions and 209 deletions

View file

@ -397,7 +397,7 @@
<em>External authentication:</em> <em>External authentication:</em>
If you want to use an external If you want to use an external
authentication system like Shibboleth or CUWebAuth, you will need to authentication system like Shibboleth or CUWebAuth, you will need to
set two additional properties in this file. See the section below set an additional property in this file. See the section below
entitled <a href="#external_auth">Using an External Authentication System with Vitro</a>. entitled <a href="#external_auth">Using an External Authentication System with Vitro</a>.
</p> </p>
<table border='1' bordercolor="#CCCCCC" cellspacing="5"> <table border='1' bordercolor="#CCCCCC" cellspacing="5">
@ -647,21 +647,16 @@
<tr> <tr>
<td colspan="2"> <td colspan="2">
If an external authentication system like Shibboleth or CUWebAuth is to be If an external authentication system like Shibboleth or CUWebAuth is to be
used, these properties say how the login button should be labeled, and which used, this property says which HTTP header will contain the user ID from
HTTP header will contain the user ID from the authentication system. If such the authentication system. If such a system is not to be used,
a system is not to be used, leave these commented out. Consult the installation leave this commented out.
instructions for more details.
</td> </td>
</tr> </tr>
<tr class="odd_row"> <tr class="odd_row">
<td> <td>
externalAuth.buttonText
<br/>
externalAuth.netIdHeaderName externalAuth.netIdHeaderName
</td> </td>
<td> <td>
Log in using BearCat Shibboleth
<br/>
remote_userID remote_userID
</td> </td>
</tr> </tr>
@ -1081,14 +1076,19 @@
the Vitro login form. You need to tell Vitro what text should appear in the Vitro login form. You need to tell Vitro what text should appear in
that button. that button.
<p> <p>
Put a line like this in the runtime.properties file: In your theme, add a line to the <code>all.properties</code> file,
externalAuth.buttonText = [the text for your login button] For example: like this one:
</p> <pre>external_login_text = <em>[the text for your login button]</em></pre>
<pre>externalAuth.buttonText = Log in using BearCat Shibboleth</pre> For example:
<p> <pre>external_login_text = Log in using BearCat Shibboleth</pre>
The Vitro login form will display a button labelled "Log in The Vitro login form will display a button labelled "Log in
using BearCat Shibboleth". using BearCat Shibboleth".
</p> </p>
<p>
If your site supports additional languages, add lines to the corresponding files.
For example, <code>all_es.properties</code> might contain this line:
<pre>external_login_text = Entrar usando Shibboleth GatoOso</pre>
</p>
</li> </li>
<li> <li>
<h5>Associating a User with a profile page.</h5> <h5>Associating a User with a profile page.</h5>

View file

@ -101,12 +101,10 @@ selfEditing.idMatchingProperty = http://vitro.mydomain.edu/ns#networkId
# #
# If an external authentication system like Shibboleth or CUWebAuth is to be # If an external authentication system like Shibboleth or CUWebAuth is to be
# used, these properties say how the login button should be labeled, and which # used, this property says which HTTP header will contain the user ID from
# HTTP header will contain the user ID from the authentication system. If such # the authentication system. If such a system is not to be used, leave this
# as system is not to be used, leave these commented out. Consult the # commented out. Consult the installation instructions for more details.
# installation instructions for more details.
# #
#externalAuth.buttonText = Log in using BearCat Shibboleth
#externalAuth.netIdHeaderName = remote_userID #externalAuth.netIdHeaderName = remote_userID
# #

View file

@ -651,6 +651,7 @@ javascript_require_to_edit = Para editar el contenido, tendrá que activar JavaS
javascript_instructions = java script de instrucciones javascript_instructions = java script de instrucciones
to_enable_javascript = Aquí están las instrucciones para habilitar JavaScript en su navegador web to_enable_javascript = Aquí están las instrucciones para habilitar JavaScript en su navegador web
external_auth_name = Nombre de autenticación externo external_auth_name = Nombre de autenticación externo
external_login_text = Entrar usando Shibboleth GatoOso
account = cuenta account = cuenta
change_password_to_login = Cambiar contraseña para iniciar sesión en change_password_to_login = Cambiar contraseña para iniciar sesión en
new_password_capitalized = Nueva contraseña new_password_capitalized = Nueva contraseña

View file

@ -2,12 +2,12 @@
package edu.cornell.mannlib.vitro.webapp.web.widgets; package edu.cornell.mannlib.vitro.webapp.web.widgets;
import java.io.IOException;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -126,8 +126,7 @@ public class LoginWidget extends Widget {
/** /**
* User is starting the login process. Show them the login screen. * User is starting the login process. Show them the login screen.
*/ */
private WidgetTemplateValues showLoginScreen(HttpServletRequest request, String siteName) private WidgetTemplateValues showLoginScreen(HttpServletRequest request, String siteName) {
throws IOException {
LoginProcessBean bean = LoginProcessBean.getBean(request); LoginProcessBean bean = LoginProcessBean.getBean(request);
log.trace("Going to login screen: " + bean); log.trace("Going to login screen: " + bean);
@ -135,13 +134,12 @@ public class LoginWidget extends Widget {
values.put(TemplateVariable.FORM_ACTION.toString(), getAuthenticateUrl(request)); values.put(TemplateVariable.FORM_ACTION.toString(), getAuthenticateUrl(request));
values.put(TemplateVariable.LOGIN_NAME.toString(), bean.getUsername()); values.put(TemplateVariable.LOGIN_NAME.toString(), bean.getUsername());
String externalAuthDisplayName = ConfigurationProperties.getBean( boolean showExternalAuth = StringUtils.isNotBlank(
request).getProperty("externalAuth.buttonText"); ConfigurationProperties.getBean(request).getProperty(
if (externalAuthDisplayName != null) { "externalAuth.netIdHeaderName"));
if (showExternalAuth) {
values.put(TemplateVariable.EXTERNAL_AUTH_URL.toString(), values.put(TemplateVariable.EXTERNAL_AUTH_URL.toString(),
UrlBuilder.getUrl(EXTERNAL_AUTH_SETUP_URL)); UrlBuilder.getUrl(EXTERNAL_AUTH_SETUP_URL));
values.put(TemplateVariable.EXTERNAL_AUTH_NAME.toString(),
externalAuthDisplayName);
} }
String infoMessage = bean.getInfoMessageAndClear(); String infoMessage = bean.getInfoMessageAndClear();

View file

@ -661,6 +661,7 @@ javascript_require_to_edit = In order to edit content, you'll need to enable Jav
javascript_instructions = java script instructions javascript_instructions = java script instructions
to_enable_javascript = Here are the instructions for enabling JavaScript in your web browser to_enable_javascript = Here are the instructions for enabling JavaScript in your web browser
external_auth_name = external authentication name external_auth_name = external authentication name
external_login_text = Log in using BearCat Shibboleth
account = account account = account
change_password_to_login = Change Password to Log in change_password_to_login = Change Password to Log in
new_password_capitalized = New Password new_password_capitalized = New Password

View file

@ -47,7 +47,7 @@
<#if externalAuthUrl??> <#if externalAuthUrl??>
<#assign infoClassHide = 'class="vivoAccount"'/> <#assign infoClassHide = 'class="vivoAccount"'/>
<p class="external-auth"><a class="blue button" href="${externalAuthUrl}" title="${i18n().external_auth_name}">${externalAuthName}</a></p> <p class="external-auth"><a class="blue button" href="${externalAuthUrl}" title="${i18n().external_auth_name}">${i18n().external_login_text}</a></p>
<!--<p class="or-auth">or</p>--> <!--<p class="or-auth">or</p>-->
<h3 class="internal-auth"><!--Log in using your--> <b>${i18n().or}</b> ${siteName} ${i18n().account}</h3> <h3 class="internal-auth"><!--Log in using your--> <b>${i18n().or}</b> ${siteName} ${i18n().account}</h3>