summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-03-05 18:19:14 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-03-05 18:19:14 +0100
commit8d353fcf9df1fa2acaf10ff3545a0b3d96810dfb (patch)
tree7b843a6abf0c7b3a15a217dfbb05755fc9a22dd1 /index.pl
parent32f3334b5cb270201c553f16e407c5567ea7cccd (diff)
registration: more error handling
Diffstat (limited to 'index.pl')
-rwxr-xr-xindex.pl39
1 files changed, 35 insertions, 4 deletions
diff --git a/index.pl b/index.pl
index 1b3a661..856327c 100755
--- a/index.pl
+++ b/index.pl
@@ -6,7 +6,7 @@ use Cache::File;
use DateTime;
use DBI;
use Encode qw(decode encode);
-use Email::Sender::Simple qw(sendmail);
+use Email::Sender::Simple qw(try_to_sendmail);
use Email::Simple;
use Geo::Distance;
use List::Util qw(first);
@@ -504,11 +504,26 @@ helper 'get_user_id' => sub {
$user_name //= $self->get_user_name;
if ( not -e $dbname ) {
+ $self->app->dbh->begin_work;
+ $self->app->dbh->do(
+ qq{
+ create table schema_version (
+ version integer primary key
+ );
+ }
+ );
$self->app->dbh->do(
qq{
create table users (
id integer primary key,
- name char(64) not null unique
+ name char(64) not null unique,
+ status int not null,
+ is_public bool not null,
+ email char(256),
+ password text,
+ registered_at datetime not null,
+ last_login datetime not null,
+ deletion_requested datetime
)
}
);
@@ -540,6 +555,12 @@ helper 'get_user_id' => sub {
)
}
);
+ $self->app->dbh->do(
+ qq{
+ insert into schema_version (version) values (1);
+ }
+ );
+ $self->app->dbh->commit;
}
$self->app->get_userid_query->execute($user_name);
@@ -987,6 +1008,11 @@ post '/x/register' => sub {
return;
}
+ if ( not length($email) ) {
+ $self->render( 'register', invalid => 'mail_empty' );
+ return;
+ }
+
if ( $user !~ m{ ^ [0-9a-zA-Z_-]+ $ }x ) {
$self->render( 'register', invalid => 'user_format' );
return;
@@ -1038,8 +1064,13 @@ post '/x/register' => sub {
);
# TODO re-enable once remaining registration code is complete
- #sendmail($reg_mail);
- #$self->render( 'login', from => 'register' );
+ #my $success = try_to_sendmail($reg_mail);
+ #if ($success) {
+ # $self->render( 'login', from => 'register' );
+ #}
+ #else {
+ # $self->render( 'register', invalid => 'sendmail' );
+ #}
$self->render( 'register', invalid => 'not implemented yet' );
};