Validate email format server-side

Also cleanup the invite action handler
master
Daniel Berteaud 11 years ago
parent a4d2a0769a
commit a44ddff81a
  1. 24
      public/vroom.pl

@ -655,7 +655,12 @@ post '/action' => sub {
if ($action eq 'invite'){ if ($action eq 'invite'){
my $rcpt = $self->param('recipient'); my $rcpt = $self->param('recipient');
my $message = $self->param('message'); my $message = $self->param('message');
$self->email( my $status = 'error';
my $msg = $self->l('ERROR_OCCURED');
if ($rcpt !~ m/\S+@\S+\.\S+$/){
$msg = $self->l('ERROR_MAIL_INVALID');
}
elsif ($self->email(
header => [ header => [
Subject => encode("MIME-Header", $self->l("EMAIL_INVITATION")), Subject => encode("MIME-Header", $self->l("EMAIL_INVITATION")),
To => $rcpt To => $rcpt
@ -665,18 +670,15 @@ post '/action' => sub {
room => $room, room => $room,
message => $message message => $message
], ],
) || )){
return $self->render( $self->app->log->info($self->session('name') . " sent an invitation for room $room to $rcpt");
json => { $status = 'success';
msg => $self->l('ERROR_OCCURED'), $msg = sprintf($self->l('INVITE_SENT_TO_s'), $rcpt);
status => 'error' }
},
);
$self->app->log->info($self->session('name') . " sent an invitation for room $room to $rcpt");
$self->render( $self->render(
json => { json => {
msg => sprintf($self->l('INVITE_SENT_TO_s'), $rcpt), msg => $msg,
status => 'success' status => $status
} }
); );
} }

Loading…
Cancel
Save