diff --git a/maacom.pl b/maacom.pl index 35b7a39..fe04270 100755 --- a/maacom.pl +++ b/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, diff --git a/schema.sql b/schema.sql index d5c2452..19cde93 100644 --- a/schema.sql +++ b/schema.sql @@ -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, diff --git a/templs/alias-add-form.html.ep b/templs/alias-add-form.html.ep index 2696502..b962cdb 100644 --- a/templs/alias-add-form.html.ep +++ b/templs/alias-add-form.html.ep @@ -21,11 +21,11 @@