X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=lib%2FNDWeb%2FController%2FSettings.pm;h=f95a97922373f9853649ad4f3091fb1b117f97d4;hb=c7e26c754fc09d8837b5801bce4046c2493cf8a9;hp=3f09a435f8e57979dfa99e37b466432c901900bb;hpb=d5a506d05cc2bf53a76b6bf4beef12a34aedf023;p=ndwebbie.git diff --git a/lib/NDWeb/Controller/Settings.pm b/lib/NDWeb/Controller/Settings.pm index 3f09a43..f95a979 100644 --- a/lib/NDWeb/Controller/Settings.pm +++ b/lib/NDWeb/Controller/Settings.pm @@ -112,10 +112,16 @@ sub changePassword : Local { my ( $self, $c ) = @_; my $dbh = $c->model; - my $query = $dbh->prepare(q{UPDATE users SET password = MD5($1) - WHERE password = MD5($2) AND uid = $3 + if (length $c->req->param('pass') < 4) { + $c->flash(error => "Your password need to be at least 4 characters"); + } else { + my $query = $dbh->prepare(q{UPDATE users SET password = $1 + WHERE password = crypt($2,password) AND uid = $3 }); - $query->execute($c->req->param('pass'),$c->req->param('oldpass'),$c->user->id); + $query->execute($c->req->param('pass'),$c->req->param('oldpass'),$c->user->id); + + $c->flash(error => "Old password was invalid") unless $query->rows; + } $c->res->redirect($c->uri_for('')); } @@ -126,6 +132,16 @@ sub changeEmail : Local { my $email = $c->req->param('email'); + if ($email =~ /^s?$/) { + my $update = $dbh->prepare(q{ +UPDATE users SET email = NULL WHERE uid = $1; + }); + $update->execute($c->user->id); + $c->flash(error => 'email cleared'); + $c->res->redirect($c->uri_for('')); + return, + } + unless (Email::Valid->address($email)){ $c->flash(email => $email); $c->flash(error => 'Invalid email address'); @@ -142,7 +158,7 @@ INSERT INTO email_change (uid,email) VALUES ($1,$2) RETURNING id; my ($id) = $insert->fetchrow_array; my %mail = ( - smtp => 'ruin.nu', + smtp => 'localhost', To => $email, From => 'NewDawn Command ', 'Content-type' => 'text/plain; charset="UTF-8"',