diff options
author | Chris Mytton <self@hecticjeff.net> | 2013-10-15 14:04:16 +0100 |
---|---|---|
committer | Chris Mytton <self@hecticjeff.net> | 2013-10-15 14:04:16 +0100 |
commit | 342dac24c58c0493dd32726bd4c05a9ba61fba0b (patch) | |
tree | 8397be9ad583be4f60c37d903fe34c653d95116e | |
parent | 82efeac919e758a3b8bd833e5dba452d470c70da (diff) |
[Zurich] Add user email address validation to the admin
Closes mysociety/FixMyStreet-Commercial#426
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 10 | ||||
-rw-r--r-- | templates/web/default/admin/user-form.html | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 424f68ba3..6264d1a73 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -961,6 +961,11 @@ sub user_add : Path('user_edit') : Args(0) { $c->forward('check_token'); + if ( $c->cobrand->moniker eq 'zurich' and $c->req->param('email') eq '' ) { + $c->stash->{field_errors}->{email} = _('The email field is required'); + return 1; + } + return unless $c->req->param('name') && $c->req->param('email'); my $user = $c->model('DB::User')->find_or_create( { @@ -1008,6 +1013,11 @@ sub user_edit : Path('user_edit') : Args(1) { $user->email( $c->req->param('email') ); $user->from_body( $c->req->param('body') || undef ); $user->flagged( $c->req->param('flagged') || 0 ); + + if ( $c->cobrand->moniker eq 'zurich' and $user->email eq '' ) { + $c->stash->{field_errors}->{email} = _('The email field is required'); + return 1; + } $user->update; if ($edited) { diff --git a/templates/web/default/admin/user-form.html b/templates/web/default/admin/user-form.html index 489752d8c..4a57b05a0 100644 --- a/templates/web/default/admin/user-form.html +++ b/templates/web/default/admin/user-form.html @@ -1,6 +1,10 @@ <form method="post" action="[% c.uri_for( 'user_edit', user.id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> <input type="hidden" name="token" value="[% token %]" > <input type="hidden" name="submit" value="1" > + + [% IF c.cobrand.moniker == 'zurich' AND field_errors.email %] + <p class='error'>[% field_errors.email %]</p> + [% END %] <ul class="no-bullets"> <li> <div class="admin-hint"> |