Modify Username on Input?
Richard Frovarp
richard.frovarp at ndsu.edu
Mon Nov 7 14:44:55 EST 2016
On 11/07/2016 01:31 PM, Rich Graves wrote:
> You'll probably have an easier time doing it in client-side
> JavaScript. Any web developer ought to be able to help you. Add an
> "onBlur" function reference to the j_username element in
> /opt/shibboleth-idp/views/login.vm.
>
> (And once you've thoroughly debugged it, let me know, ok, because this
> is something I could use too.)
>
>
We've done JS and server side. I don't think it matters for Shibboleth,
but we also had issues in the past where the username coming out of CAS
was cased to how the user typed it.
function removeDomainFromUsername() {
var usernameField = document.getElementById("username");
var username = usernameField.value;
var handle = username.substring(0,
username.lastIndexOf("@"));
if (handle.length > 0) {
usernameField.value = handle;
}
}
<input autofocus class="form-element form-field" id="username"
name="j_username" onBlur="removeDomainFromUsername();" type="text"
value="#if($username)$encoder.encodeForHTML($username)#end">
<!-- Apply any regular expression replacement pairs before
validation. -->
<util:list id="shibboleth.authn.Password.Transforms">
<!-- Get the right username -->
<bean parent="shibboleth.Pair" p:first="^(.+)@.*$" p:second="$1" />
</util:list>
We really don't care what domain you put in, we just want it to drop it
off. Given that about half of the systems require a domain, and other
other half require that the domain is missing, we figured it was good to
make these work no matter what your muscle memory does.
Unfortunately, this doesn't handle leading or trailing whitespace. Going
to have to figure out how and where to take care of that. Autocomplete
from keyboards can end up putting that in, and it is frustrating when
that isn't handled.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20161107/7a9cadc4/attachment.html>
More information about the users
mailing list