MT#6789 Add password recovery components.

ipeshinskaya/InvoiceTemplate5
Andreas Granig 12 years ago
parent bf5ec092bb
commit 256de924e3

@ -0,0 +1,48 @@
package NGCP::Panel::Form::Subscriber::ResetPassword;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';
use Moose::Util::TypeConstraints;
use HTML::FormHandler::Widget::Block::Bootstrap;
use NGCP::Panel::Field::PosInteger;
has '+widget_wrapper' => ( default => 'Bootstrap' );
has_field 'submitid' => ( type => 'Hidden' );
sub build_render_list {[qw/submitid fields actions/]}
sub build_form_element_class {[qw(form-horizontal)]}
has_field 'password' => (
type => 'Password',
required => 1,
label => 'Password',
);
has_field 'password_conf' => (
type => 'PasswordConf',
required => 1,
label => 'Repeat Password',
password_field => 'password',
);
has_field 'save' => (
type => 'Submit',
value => 'Save',
element_class => [qw/btn btn-primary/],
label => '',
);
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/password password_conf/],
);
has_block 'actions' => (
tag => 'div',
class => [qw/modal-footer/],
render_list => [qw/save/],
);
1;
# vim: set tabstop=4 expandtab:

@ -0,0 +1,71 @@
package NGCP::Panel::Utils::Email;
use Sipwise::Base;
use Template;
sub send_template {
my ($c, $vars, $subject, $body, $from, $to) = @_;
my $t = Template->new;
my $processed_body = "";
$t->process(\$body, $vars, \$processed_body) ||
die "error processing email template body, type=".$t->error->type.", info='".$t->error->info."'";
my $processed_subject = "";
$t->process(\$subject, $vars, \$processed_subject) ||
die "error processing email template, type=".$t->error->type.", info='".$t->error->info."'";
$c->email(
header => [
From => $from,
To => $to,
Subject => $processed_subject,
],
body => $processed_body,
);
return 1;
}
sub new_subscriber {
my ($c, $subscriber, $url) = @_;
my $template = $subscriber->contract->subscriber_email_template;
return unless($template);
my $email = $subscriber->contact ?
$subscriber->contact->email : $subscriber->contract->contact->email;
my $vars = {
url => $url,
subscriber => $subscriber->username . '@' . $subscriber->domain->domain,
};
my $body = $template->body;
my $subject = $template->subject;
return send_template($c, $vars, $subject, $body, $template->from_email, $email);
}
sub password_reset {
my ($c, $subscriber, $url) = @_;
my $template = $subscriber->contract->passreset_email_template;
return unless($template);
my $email = $subscriber->contact ?
$subscriber->contact->email : $subscriber->contract->contact->email;
my $vars = {
url => $url,
subscriber => $subscriber->username . '@' . $subscriber->domain->domain,
};
my $body = $template->body;
my $subject = $template->subject;
return send_template($c, $vars, $subject, $body, $template->from_email, $email);
}
1;
# vim: set tabstop=4 expandtab:

@ -0,0 +1,12 @@
[% site_config.title = c.loc('Reset Web Password') -%]
[% IF edit_flag || create_flag -%]
[%
PROCESS "helpers/modal.tt";
modal_header(m.name = c.loc('Web Password'),
m.create_flag = create_flag);
translate_form(form).render();
modal_footer();
modal_script(m.close_target = close_target);
-%]
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]
Loading…
Cancel
Save