+
+ + You requested a password reset. ++ ++ Please use the following [% link %] to reset your password. + + ++ Thanks! + + |
+
diff --git a/Web/cpanfile b/Web/cpanfile index a018675..77eff92 100644 --- a/Web/cpanfile +++ b/Web/cpanfile @@ -6,7 +6,11 @@ requires 'DateTime'; requires 'DateTime::Format::Pg'; requires 'Try::Tiny'; -# Remove when moving mail to its own package. +# For MJB::Web::Plugin::Email requires 'Email::Sender::Simple'; requires 'Email::Sender::Transport::SMTP'; requires 'Email::MIME::Kit'; +requires 'Email::MIME::Kit::Renderer::TT'; +requires 'MIME::Base64'; +requires 'Authen::SASL'; + diff --git a/Web/lib/MJB/Web.pm b/Web/lib/MJB/Web.pm index 190c486..7c765f9 100644 --- a/Web/lib/MJB/Web.pm +++ b/Web/lib/MJB/Web.pm @@ -25,8 +25,11 @@ sub startup ($self) { # Add MJB::Web::Plugin to plugin search path. push @{$self->plugins->namespaces}, 'MJB::Web::Plugin'; - # Load the MJB::Web::Plugin::Nginx plugin. + # Load the MJB::Web::Plugin::Nginx plugin for $c->domain_config $self->plugin('Nginx'); + + # Load the MJB::Web::Plugin::Email plugin for $c->send_email + $self->plugin('Email'); $self->helper( db => sub { return state $db = MJB::DB->connect($config->{database}->{mjb}); diff --git a/Web/lib/MJB/Web/Controller/Auth.pm b/Web/lib/MJB/Web/Controller/Auth.pm index 1081537..6ea4415 100644 --- a/Web/lib/MJB/Web/Controller/Auth.pm +++ b/Web/lib/MJB/Web/Controller/Auth.pm @@ -213,10 +213,10 @@ sub do_forgot ( $c ) { # Make a token & send the email TODO my $token = $person->create_auth_token( 'forgot' ); - #$c->send_email( 'forgot_password', { - # send_to => $email, - # link => 'https://' . $c->config->{domain} . "/reset/$token" - #}); + $c->send_email( 'forgot_password', { + send_to => $email, + link => 'https://' . $c->config->{domain_for_links} . "/reset/$token" + }); # Let the user know the next steps. $c->flash( confirmation => 'Please check your email for a password reset link.' ); diff --git a/Web/lib/MJB/Web/Plugin/Email.pm b/Web/lib/MJB/Web/Plugin/Email.pm index db5be07..281259b 100644 --- a/Web/lib/MJB/Web/Plugin/Email.pm +++ b/Web/lib/MJB/Web/Plugin/Email.pm @@ -8,12 +8,14 @@ sub register ( $self, $app, $config ) { $app->helper( send_email => sub ($c, $template, $options ) { my $transport = Email::Sender::Transport::SMTP->new(%{$c->config->{smtp}}); - my $mkit_path = $c->home->child('mkits')->to_string; + my $mkit_path = $app->home->child('mkits')->to_string; my $kit = Email::MIME::Kit->new({ source => sprintf( "%s/%s.mkit", $mkit_path, $template ) } ); - my $message = $kid->assemble( $options ); + my $message = $kit->assemble( $options ); sendmail( $message, { transport => $transport } ); }); } + +1; diff --git a/Web/mkits/forgot_password.mkit/body.html b/Web/mkits/forgot_password.mkit/body.html new file mode 100644 index 0000000..2dbaabb --- /dev/null +++ b/Web/mkits/forgot_password.mkit/body.html @@ -0,0 +1,74 @@ + + +
+ + +| + |
+
+
+
+
+
+
+
|
+ + |
| + |
+
+
+
+
+
+
+
|
+ + |