From 8e672a7a73dd87b9b67d139097ba0b763b8b29cf Mon Sep 17 00:00:00 2001 From: Al Beano Date: Wed, 4 Oct 2017 09:02:11 +0100 Subject: [PATCH] Collect WHOIS name on account page --- dbupdate/9.sql | 2 ++ lib/cyberman/Account.pm | 5 +++++ schema.sql | 5 +++-- views/account.tt | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 dbupdate/9.sql diff --git a/dbupdate/9.sql b/dbupdate/9.sql new file mode 100644 index 0000000..7f329d0 --- /dev/null +++ b/dbupdate/9.sql @@ -0,0 +1,2 @@ +alter table user add column whois_name text; +update cyberman set dbrev=10; diff --git a/lib/cyberman/Account.pm b/lib/cyberman/Account.pm index b5b4449..dfb808b 100644 --- a/lib/cyberman/Account.pm +++ b/lib/cyberman/Account.pm @@ -74,6 +74,10 @@ post '/account' => sub { $errs{"e_bad_privacy"} = 1; } + if (param("whois_name") !~ m/^[A-Za-z0-9 \'-]{0,64}$/) { + $errs{"e_bad_name"} = 1; + } + if (scalar(keys %errs) != 0) { return template 'account' => { "user" => $user, @@ -138,6 +142,7 @@ post '/account' => sub { { "stylesheet" => param("stylesheet"), "email_pub" => param("email_pub"), + "whois_name" => param("whois_name"), }, ); diff --git a/schema.sql b/schema.sql index 51b594a..21c18e5 100644 --- a/schema.sql +++ b/schema.sql @@ -6,7 +6,7 @@ create table cyberman ( lastserial integer not null default 0, zonecheckstatus integer not null default 0, ); -insert into cyberman (dbrev) values (9); +insert into cyberman (dbrev) values (10); drop table if exists user; create table user ( @@ -20,7 +20,8 @@ create table user ( recoverytoken text, stylesheet text, admin integer not null default 0, - email_pub integer not null default 0 + email_pub integer not null default 0, + whois_name text ); drop table if exists session; diff --git a/views/account.tt b/views/account.tt index 30a08b6..a744ba2 100644 --- a/views/account.tt +++ b/views/account.tt @@ -37,6 +37,9 @@ <% IF e_bad_privacy %>
  • Please select a value for WHOIS privacy.
  • <% END %> + <% IF e_bad_name %> +
  • The name you entered is invalid, sorry. Please use Latin characters only.
  • + <% END %> @@ -94,6 +97,18 @@ + + + + + + + value="<% user.whois_name | html_entity %>" + <% END %> + /> + +