Make "Invalid username" error message customizable
[plack-middleware-auth-complex.git] / lib / Plack / Middleware / Auth / Complex.pm
index ac70da693554a5aec710f194b3e386ba93fcf874..035a622259353c963f2577d33bcededeae519dfc 100644 (file)
@@ -32,6 +32,7 @@ sub default_opts {(
        cache_max_age     => 5 * 60,
        token_max_age     => 60 * 60,
        username_regex    => qr/^\w{2,20}$/as,
+       invalid_username  => 'Invalid username',
        register_url      => '/action/register',
        passwd_url        => '/action/passwd',
        request_reset_url => '/action/request-reset',
@@ -176,7 +177,7 @@ sub call_register {
                return $self->bad_request("Missing parameter $_") unless $parms{$_};
        }
 
-       return $self->bad_request('Username must match ' . $self->{username_regex}) unless $parms{username} =~ $self->{username_regex};
+       return $self->bad_request($self->{invalid_username}) unless $parms{username} =~ $self->{username_regex};
        return $self->bad_request('Username already in use') if $self->get_user($parms{username});
        return $self->bad_request('The two passwords do not match') unless $parms{password} eq $parms{confirm_password};
 
@@ -391,6 +392,11 @@ Password reset token validity, in seconds. Defaults to 1 hour.
 Regular expression that matches valid usernames. Defaults to
 C<qr/^\w{2,20}$/as>.
 
+=item invalid_username
+
+Error message returned when the username does not match
+username_regex. Defaults to C<'Invalid username'>
+
 =item register_url
 
 URL for registering. Defaults to C<'/action/register'>.
This page took 0.010375 seconds and 4 git commands to generate.