Added gecos field to user profile
This commit is contained in:
12
maacom.pl
12
maacom.pl
@@ -434,6 +434,7 @@ sub user_profile {
|
||||
return undef unless $id;
|
||||
$self->db->exec1("select u.id as id,
|
||||
u.name as name,
|
||||
u.gecos as gecos,
|
||||
u.name || '\@' || d.name as address,
|
||||
u.domain_id as domain_id,
|
||||
d.name as domain_name,
|
||||
@@ -451,6 +452,7 @@ sub user_list {
|
||||
my $and = "and u.domain_id = $domain_id" if $domain_id;
|
||||
$self->db->exec("select u.id as id,
|
||||
u.name as name,
|
||||
u.gecos as gecos,
|
||||
u.name || '\@' || d.name as address,
|
||||
u.domain_id as domain_id,
|
||||
d.name as domain_name,
|
||||
@@ -471,20 +473,20 @@ sub user_nextid {
|
||||
}
|
||||
|
||||
sub user_add {
|
||||
my ($self, $name, $password, $domain_id, $quota) = @_;
|
||||
my ($self, $name, $gecos, $password, $domain_id, $quota) = @_;
|
||||
return undef unless $name;
|
||||
return undef unless $password;
|
||||
return undef unless $domain_id;
|
||||
$quota ||= 1024*10;
|
||||
|
||||
$gecos ||= '';
|
||||
return undef if $self->user_exist($name, $domain_id);
|
||||
return undef unless $self->domain_profile($domain_id);
|
||||
my $next_id = $self->user_nextid;
|
||||
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, quota)
|
||||
values ($next_id, '$name', '$password', $domain_id, '$hash', $quota)");
|
||||
$self->db->do("insert into users (id, name, gecos, password, domain_id, hash, quota)
|
||||
values ($next_id, '$name', '$gecos', '$password', $domain_id, '$hash', $quota)");
|
||||
$self->user_exist($name, $domain_id);
|
||||
}
|
||||
|
||||
@@ -494,6 +496,7 @@ sub user_update {
|
||||
return undef unless $prof;
|
||||
|
||||
my $name = $args{name} || $prof->{name};
|
||||
my $gecos = $args{gecos} || $prof->{gecos};
|
||||
my $password = $args{password} || $prof->{password};
|
||||
my $hash = $prof->{hash};
|
||||
if ($args{password}) {
|
||||
@@ -507,6 +510,7 @@ sub user_update {
|
||||
$size ||= 0;
|
||||
|
||||
$self->db->do("update users set name = '$name',
|
||||
gecos = '$gecos',
|
||||
password = '$password',
|
||||
size = $size,
|
||||
quota = $quota,
|
||||
|
||||
@@ -5,9 +5,11 @@ CREATE TABLE domains (
|
||||
size int DEFAULT 0,
|
||||
quota int DEFAULT 1048576
|
||||
);
|
||||
DROP TABLE IF EXISTS users;
|
||||
CREATE TABLE users (
|
||||
id int unique NOT NULL PRIMARY KEY,
|
||||
name text,
|
||||
gecos text,
|
||||
domain_id int,
|
||||
password text,
|
||||
hash text,
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
<h5 class="text-center">Add alias to domain <%= $domain_name %></h5>
|
||||
<input type="hidden" name="domain_id" value="<%= $domain_id %>"/>
|
||||
<label>Alias name
|
||||
<input type="text" name="alias_name" placeholder="aliasname" required pattern="[_.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<input type="text" name="alias_name" placeholder="aliasname" required pattern="[_.\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<span class="form-error">Mandatory, 2 or more letter</span>
|
||||
</label>
|
||||
<label>Destination list
|
||||
<input type="text" name="list" placeholder="some@bare.org,foo@bar.com" required pattern="[_.,@a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" name="list" placeholder="some@bare.org,foo@bar.com" required pattern="[_.,@\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 6 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
@@ -47,7 +47,7 @@
|
||||
<form accept-charset="UTF-8" action="/alias/add/handler" method="post" data-abide novalidate>
|
||||
<h5 class="text-center">Add alias</h5>
|
||||
<label>Alias name
|
||||
<input type="text" name="alias_name" placeholder="aliasname" required pattern="[_.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<input type="text" name="alias_name" placeholder="aliasname" required pattern="[_.\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<span class="form-error">Mandatory, 2 or more letter</span>
|
||||
</label>
|
||||
<label>Domain
|
||||
@@ -59,7 +59,7 @@
|
||||
</select >
|
||||
</label>
|
||||
<label>Destination list
|
||||
<input type="text" name="list" placeholder="some@bare.org,foo@bar.com" required pattern="[_.@,a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" name="list" placeholder="some@bare.org,foo@bar.com" required pattern="[_.@,\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 6 or more letter</span>
|
||||
</label>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<h5 class="text-center">Edit alias <%= $address %></h5>
|
||||
<input type="hidden" name="alias_id" value="<%= $alias_id %>"/>
|
||||
<label>Alias name
|
||||
<input type="text" value="<%= $alias_name %>" name="alias_name" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<input type="text" value="<%= $alias_name %>" name="alias_name" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<span class="form-error">Mandatory, 2 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<form accept-charset="UTF-8" action="/domain/add/handler" method="post" data-abide novalidate>
|
||||
<h5 class="text-center">Add domain</h5>
|
||||
<label>Domain name
|
||||
<input type="text" name="domain_name" placeholder="domain.org" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" name="domain_name" placeholder="domain.org" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<h5 class="text-center">Edit domain</h5>
|
||||
<input type="hidden" name="domain_id" value="<%= $domain_id %>"/>
|
||||
<label>Domain name
|
||||
<input type="text" value="<%= $domain_name %>" name="domain_name" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" value="<%= $domain_name %>" name="domain_name" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<form accept-charset="UTF-8" action="/forwarded/add/handler" method="post" data-abide novalidate>
|
||||
<h5 class="text-center">Add forwardeded domain</h5>
|
||||
<label>Domain name
|
||||
<input type="text" name="forwarded_name" placeholder="domain.org" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" name="forwarded_name" placeholder="domain.org" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<h5 class="text-center">Edit domain</h5>
|
||||
<input type="hidden" name="forwarded_id" value="<%= $forwarded_id %>"/>
|
||||
<label>Domain name
|
||||
<input type="text" value="<%= $forwarded_name %>" name="forwarded_name" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" value="<%= $forwarded_name %>" name="forwarded_name" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<form accept-charset="UTF-8" action="/trusted/add/handler" method="post" data-abide novalidate>
|
||||
<h5 class="text-center">Add trusted host</h5>
|
||||
<label>Host name
|
||||
<input type="text" name="trusted_name" placeholder="host.org" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" name="trusted_name" placeholder="host.org" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<h5 class="text-center">Edit host</h5>
|
||||
<input type="hidden" name="trusted_id" value="<%= $trusted_id %>"/>
|
||||
<label>Host name
|
||||
<input type="text" value="<%= $trusted_name %>" name="trusted_name" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" value="<%= $trusted_name %>" name="trusted_name" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<form accept-charset="UTF-8" action="/unwanted/add/handler" method="post" data-abide novalidate>
|
||||
<h5 class="text-center">Add unwanted host</h5>
|
||||
<label>Host name
|
||||
<input type="text" name="unwanted_name" placeholder="host.org" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" name="unwanted_name" placeholder="host.org" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<h5 class="text-center">Edit host</h5>
|
||||
<input type="hidden" name="unwanted_id" value="<%= $unwanted_id %>"/>
|
||||
<label>Host name
|
||||
<input type="text" value="<%= $unwanted_name %>" name="unwanted_name" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" value="<%= $unwanted_name %>" name="unwanted_name" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 5 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
|
||||
@@ -22,11 +22,16 @@
|
||||
<h5 class="text-center">Add user to domain <%= $domain_name %></h5>
|
||||
<input type="hidden" name="domain_id" value="<%= $domain_id %>"/>
|
||||
<label>Username
|
||||
<input type="text" name="user_name" placeholder="username" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<input type="text" name="user_name" placeholder="username" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<span class="form-error">Mandatory, 2 or more letter</span>
|
||||
</label>
|
||||
|
||||
<label>Gecos
|
||||
<input type="text" name="gecos" placeholder="first second names"/>
|
||||
</label>
|
||||
|
||||
<label>Password
|
||||
<input type="text" name="password" placeholder="xxxxxxxxx" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" name="password" placeholder="xxxxxxxxx" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 6 or more letter</span>
|
||||
</label>
|
||||
|
||||
@@ -54,11 +59,11 @@
|
||||
<form accept-charset="UTF-8" action="/user/add/handler" method="post" data-abide novalidate>
|
||||
<h5 class="text-center">Add user</h5>
|
||||
<label>Username
|
||||
<input type="text" name="user_name" placeholder="username" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<input type="text" name="user_name" placeholder="username" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<span class="form-error">Mandatory, 2 or more letter</span>
|
||||
</label>
|
||||
<label>Password
|
||||
<input type="text" name="password" placeholder="xxxxxxxxx" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<input type="text" name="password" placeholder="xxxxxxxxx" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{5,42}"/>
|
||||
<span class="form-error">Mandatory, 6 or more letter</span>
|
||||
</label>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
% my $user_name = $c->req->param('user_name');
|
||||
% my $domain_id = $c->req->param('domain_id');
|
||||
% my $gecos = $c->req->param('gecos');
|
||||
% my $password = $c->req->param('password');
|
||||
% my $quota = $c->req->param('quota');
|
||||
|
||||
@@ -21,7 +22,7 @@
|
||||
% }
|
||||
|
||||
% unless ($cid) {
|
||||
% my $id = $u->user_add($user_name, $password, $domain_id, $quota);
|
||||
% my $id = $u->user_add($user_name, $gecos, $password, $domain_id, $quota);
|
||||
% if ($id) {
|
||||
<div class="callout success">User <%= $user_name %> has been added.</div>
|
||||
% }
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>address</th>
|
||||
<th><i class="fi-info"></i></th>
|
||||
<th><i class="fi-graph-pie"></i></th>
|
||||
<th><i class="fi-alert"></i></th>
|
||||
<th><i class="fi-address-book"></i></th>
|
||||
@@ -40,6 +41,7 @@
|
||||
% foreach my $row (@$list) {
|
||||
% $n += 1;
|
||||
% my $address = $row->{address};
|
||||
% my $gecos = $row->{gecos};
|
||||
% my $user_id = $row->{id};
|
||||
% my $domain_id = $row->{domain_id};
|
||||
% my $size = $row->{size} || 0;
|
||||
@@ -47,6 +49,7 @@
|
||||
<tr>
|
||||
<td><%= $n %></td>
|
||||
<td><%= $address %></td>
|
||||
<td><%= $gecos %></td>
|
||||
<td><%= $size %></td>
|
||||
<td><%= $quota %></td>
|
||||
<td><a href="/user/rename/form?user_id=<%= $user_id %>"><i class="fi-address-book"></i></a></td>
|
||||
@@ -74,6 +77,7 @@
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>address</th>
|
||||
<td><i class="fi-info"></i></td>
|
||||
<th><i class="fi-graph-pie"></i></th>
|
||||
<th><i class="fi-alert"></i></th>
|
||||
<th><i class="fi-at-sign"></i></th>
|
||||
@@ -88,6 +92,7 @@
|
||||
% foreach my $row (@$list) {
|
||||
% $n += 1;
|
||||
% my $address = $row->{address};
|
||||
% my $gecos = $row->{gecos};
|
||||
% my $user_id = $row->{id};
|
||||
% my $domain_id = $row->{domain_id};
|
||||
% my $size = $row->{size} || 0;
|
||||
@@ -95,6 +100,7 @@
|
||||
<tr>
|
||||
<td><%= $n %></td>
|
||||
<td><%= $address %></td>
|
||||
<td><%= $gecos %></td>
|
||||
<td><%= $size %></td>
|
||||
<td><%= $quota %></td>
|
||||
<td><a href="/user/list?domain_id=<%= $domain_id %>"><i class="fi-at-sign"></i></a></td>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<h5 class="text-center">Rename user <%= $address %></h5>
|
||||
<input type="hidden" name="user_id" value="<%= $user_id %>"/>
|
||||
<label>Username
|
||||
<input type="text" value="<%= $user_name %>" name="user_name" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<input type="text" value="<%= $user_name %>" name="user_name" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,42}"/>
|
||||
<span class="form-error">Mandatory, 2 or more letter</span>
|
||||
</label>
|
||||
<div class="text-center">
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
% if ($profile) {
|
||||
% my $user_name = $profile->{name};
|
||||
% my $gecos = $profile->{gecos};
|
||||
% my $domain_name = $profile->{domain_name};
|
||||
% my $domain_id = $profile->{domain_id};
|
||||
% my $password = $profile->{password};
|
||||
@@ -26,8 +27,11 @@
|
||||
<form accept-charset="UTF-8" action="/user/update/handler" method="post" data-abide novalidate>
|
||||
<h5 class="text-center">Edit user <%= $address %></h5>
|
||||
<input type="hidden" name="user_id" value="<%= $user_id %>"/>
|
||||
<label>Gecos
|
||||
<input type="text" value="<%= $gecos %>" name="gecos"/>
|
||||
</label>
|
||||
<label>Password
|
||||
<input type="text" value="<%= $password %>" name="password" required pattern="[_.-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{6,42}"/>
|
||||
<input type="text" value="<%= $password %>" name="password" required pattern="[_\.a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{6,42}"/>
|
||||
<span class="form-error">Mandatory, 6 or more letter</span>
|
||||
</label>
|
||||
<label>Quota
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
% my $u = $c->app->user;
|
||||
|
||||
% my $user_id = $c->req->param('user_id') || 0;
|
||||
% my $gecos = $c->req->param('gecos');
|
||||
% my $password = $c->req->param('password');
|
||||
% my $quota = $c->req->param('quota');
|
||||
|
||||
@@ -20,7 +21,7 @@
|
||||
% my $address = $profile->{address};
|
||||
% my $quota = $quota || $profile->{quota};
|
||||
|
||||
% my $res = $u->user_update($user_id, password => $password, quota => $quota);
|
||||
% my $res = $u->user_update($user_id, gecos => $gecos, password => $password, quota => $quota);
|
||||
% if ($res) {
|
||||
<div class="callout success">User <%= $address %> has been updated.</div>
|
||||
% }
|
||||
|
||||
Reference in New Issue
Block a user