From b5caee2df4f5f3afffb5f5189a3162ed1f87954a Mon Sep 17 00:00:00 2001 From: ziggi Date: Thu, 14 Dec 2017 23:36:44 +0200 Subject: [PATCH] Added quota to form --- maacom.pl | 11 +++++------ schema.sql | 2 +- templs/user-add-form.html.ep | 7 +++++++ templs/user-add-handler.html.ep | 4 +++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/maacom.pl b/maacom.pl index 3cc3547..f3f5360 100755 --- a/maacom.pl +++ b/maacom.pl @@ -467,10 +467,11 @@ sub user_nextid { } sub user_add { - my ($self, $name, $password, $domain_id) = @_; + my ($self, $name, $password, $domain_id, $quota) = @_; return undef unless $name; return undef unless $password; return undef unless $domain_id; + $quota ||= 1024*1024*1024*10; return undef if $self->user_exist($name, $domain_id); return undef unless $self->domain_profile($domain_id); @@ -478,8 +479,8 @@ sub user_add { my $salt = substr(sha512_base64(sprintf("%X", rand(2**31-1))), 4, 16); my $hash = crypt($password,'$6$'.$salt.'$'); - $self->db->do("insert into users (id, name, password, domain_id, hash) - values ($next_id, '$name', '$password', $domain_id, '$hash')"); + $self->db->do("insert into users (id, name, password, domain_id, hash, $quota) + values ($next_id, '$name', '$password', $domain_id, '$hash', $quota)"); $self->user_exist($name, $domain_id); } @@ -1340,9 +1341,7 @@ $app->log(Mojo::Log->new( my $user = $app->config('user'); my $group = $app->config('group'); my $d = Daemon->new($user, $group); -$d->fork; - - +#$d->fork; $app->hook(before_dispatch => sub { my $c = shift; diff --git a/schema.sql b/schema.sql index 31b6f50..9c897e4 100644 --- a/schema.sql +++ b/schema.sql @@ -12,7 +12,7 @@ CREATE TABLE users ( password text, hash text, size int DEFAULT 0, - quota int DEFAULT 0 + quota int DEFAULT 10737418240 ); CREATE TABLE aliases ( id int unique NOT NULL PRIMARY KEY, diff --git a/templs/user-add-form.html.ep b/templs/user-add-form.html.ep index a7933f3..67c2188 100644 --- a/templs/user-add-form.html.ep +++ b/templs/user-add-form.html.ep @@ -13,6 +13,7 @@ % if ($domain_id) { % my $profile = $u->domain_profile($domain_id); % my $domain_name = $profile->{name}; + % my $quota = 1024*1024*1024*10;
@@ -28,6 +29,12 @@ Mandatory, 6 or more letter + + +
Escape diff --git a/templs/user-add-handler.html.ep b/templs/user-add-handler.html.ep index b4c9b0d..d38a130 100644 --- a/templs/user-add-handler.html.ep +++ b/templs/user-add-handler.html.ep @@ -11,6 +11,8 @@ % my $user_name = $c->req->param('user_name'); % my $domain_id = $c->req->param('domain_id'); % my $password = $c->req->param('password'); +% my $quota = $c->req->param('quota'); + % my $cid = $u->user_exist($user_name, $domain_id); @@ -19,7 +21,7 @@ % } % unless ($cid) { - % my $id = $u->user_add($user_name, $password, $domain_id); + % my $id = $u->user_add($user_name, $password, $domain_id, $quota); % if ($id) {
User <%= $user_name %> has been added.
% }