aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas <skangas@skangas.se>2011-03-14 20:54:51 +0100
committerStefan Kangas <skangas@skangas.se>2011-03-14 20:54:51 +0100
commit68708cd2430d4da548673fd612c891413448fddf (patch)
tree3c0864376422afebb9dc048a113ce4b7839f3dd3
parentc6d17eebc6f40188a33fa8aca863129ed57868e9 (diff)
Send password with credentials mail
-rwxr-xr-xfripost-adduser2
-rwxr-xr-xfripost-passwd21
-rwxr-xr-xlib/Fripost/Prompt.pm2
-rw-r--r--lib/Fripost/Schema/Result/Mailbox.pm18
-rw-r--r--templ/new_user_mail.tt4
5 files changed, 27 insertions, 20 deletions
diff --git a/fripost-adduser b/fripost-adduser
index a4ab077..ba97cdf 100755
--- a/fripost-adduser
+++ b/fripost-adduser
@@ -66,7 +66,7 @@ my $user;
password => $password,
};
- say "User name: $user->{username}";
+ say "User name: $user->{username}";
say "Real name: $user->{name}";
say "Password: (hidden)";
diff --git a/fripost-passwd b/fripost-passwd
index ad835b0..c01ca4b 100755
--- a/fripost-passwd
+++ b/fripost-passwd
@@ -13,22 +13,12 @@ fripost-passwd - Change password of user
use FindBin qw($Bin);
use lib "$Bin/lib";
-our $VERSION = '0.01';
-
use Fripost::Password;
use Fripost::Prompt;
use Fripost::Schema;
use Getopt::Long;
use YAML::Syck;
-my $username = $ARGV[0];
-$username //= prompt_username();
-my $password = prompt_password();
-
-# Show the information that will be inserted
-say "Password: $password";
-say "Salted MD5: " . smd5($password);
-
## Get command line options
our $conf = LoadFile('default.yml');
@@ -39,6 +29,10 @@ GetOptions(
'pretend' => \$conf->{pretend},
) or die "Unable to get command line options.";
+my $username = $ARGV[0];
+$username //= prompt_email("New username: ", 'is_user');
+my $password = prompt_password();
+
if ($conf->{pretend}) {
say "Nothing to do since we are pretending...";
exit 0;
@@ -48,17 +42,12 @@ if ($conf->{pretend}) {
my $schema = Fripost::Schema->connect(
$conf->{dbi_dsn}, $conf->{admuser}, $conf->{admpass}, {} #\%dbi_params
);
-
my $row = $schema->resultset('Mailbox')->find($username);
-
-$row->password(smd5($password));
-
+$row->password($password);
$row->update;
say "Updated password for $username.";
-# TODO: ändra changedate vid varje insert
-
=head1 AUTHOR
Stefan Kangas C<< <skangas at skangas.se> >>
diff --git a/lib/Fripost/Prompt.pm b/lib/Fripost/Prompt.pm
index 03c5fc4..b41f806 100755
--- a/lib/Fripost/Prompt.pm
+++ b/lib/Fripost/Prompt.pm
@@ -82,7 +82,7 @@ sub prompt_password {
);
say "Using password: $password";
}
- return smd5($password);
+ return $password;
}
=head1 AUTHOR
diff --git a/lib/Fripost/Schema/Result/Mailbox.pm b/lib/Fripost/Schema/Result/Mailbox.pm
index f12e1f7..48d81fb 100644
--- a/lib/Fripost/Schema/Result/Mailbox.pm
+++ b/lib/Fripost/Schema/Result/Mailbox.pm
@@ -6,6 +6,8 @@ use strict;
use base qw/DBIx::Class::Core/;
+use Fripost::Password;
+
# mysql> describe mailbox;
# +-------------+--------------+------+-----+---------------------+-------+
# | Field | Type | Null | Key | Default | Extra |
@@ -32,6 +34,22 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key('username');
+=head2 store_column
+
+override store_column to encrypt the password when stored
+
+=cut
+
+sub store_column {
+ my ($self, $col, $val) = @_;
+
+ if ($col eq 'password') {
+ $val = smd5($val);
+ }
+
+ return $self->next::method($col,$val);
+}
+
=head1 NAME
Fripost::Schema::Result::Mailbox -
diff --git a/templ/new_user_mail.tt b/templ/new_user_mail.tt
index ba72c57..82eeac6 100644
--- a/templ/new_user_mail.tt
+++ b/templ/new_user_mail.tt
@@ -4,11 +4,11 @@ Allmänna frågor kring programmen, webmailen eller konfiguration av
e-postprogram tas bäst på e-postlistan så att svaren kan komma alla
till del.
-Du kan bli medlem genom att skicka ett mail till
+Du kan bli medlem på e-postlistan genom att skicka ett mail till:
members-subscribe@lists.fripost.org
-Frågor gällande specifikt ditt konto kan du ta direkt med administratörerna.
+Frågor gällande specifikt ditt konto kan du ta direkt med administratörerna:
admin@fripost.org