diff --git a/lib/NGCP/Panel/Form/Subscriber/ResetPassword.pm b/lib/NGCP/Panel/Form/Subscriber/ResetPassword.pm new file mode 100644 index 0000000000..35f6d0d1b0 --- /dev/null +++ b/lib/NGCP/Panel/Form/Subscriber/ResetPassword.pm @@ -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: diff --git a/lib/NGCP/Panel/Utils/Email.pm b/lib/NGCP/Panel/Utils/Email.pm new file mode 100644 index 0000000000..30421072db --- /dev/null +++ b/lib/NGCP/Panel/Utils/Email.pm @@ -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: diff --git a/share/templates/subscriber/recoverpassword.tt b/share/templates/subscriber/recoverpassword.tt new file mode 100644 index 0000000000..f7dee33150 --- /dev/null +++ b/share/templates/subscriber/recoverpassword.tt @@ -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: -%]