MT#5859 let subscriber change his webpassword

agranig/pbxapi
Gerhard Jungwirth 12 years ago
parent 4e6e9efb92
commit f99ce65102

@ -32,6 +32,7 @@ use NGCP::Panel::Form::Voicemail::Email;
use NGCP::Panel::Form::Voicemail::Attach;
use NGCP::Panel::Form::Voicemail::Delete;
use NGCP::Panel::Form::Reminder;
use NGCP::Panel::Form::Subscriber::EditWebpass;
use NGCP::Panel::Form::Subscriber::TrustedSource;
use NGCP::Panel::Form::Subscriber::Location;
use NGCP::Panel::Form::Subscriber::SpeedDial;
@ -1793,9 +1794,6 @@ sub master :Chained('base') :PathPart('details') :CaptureArgs(0) {
attribute => 'lock',
prov_subscriber => $c->stash->{subscriber}->provisioning_voip_subscriber,
);
$c->stash(
template => 'subscriber/master.tt',
);
}
sub details :Chained('master') :PathPart('') :Args(0) :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) :AllowedRole('subscriberadmin') {
@ -2096,6 +2094,65 @@ sub aliases_ajax :Chained('master') :PathPart('aliases/ajax') :Args(0) :Does(ACL
$c->detach( $c->view("JSON") );
}
sub webpass :Chained('base') :PathPart('webpass') :Args(0) {
my ($self, $c) = @_;
$c->detach('/denied_page')
if(($c->user->roles eq "admin" || $c->user->roles eq "reseller") && $c->user->read_only);
$c->stash(
template => 'subscriber/edit_webpass.tt',
);
}
sub webpass_edit :Chained('base') :PathPart('webpass/edit') :Args(0) {
my ($self, $c) = @_;
$c->detach('/denied_page')
if(($c->user->roles eq "admin" || $c->user->roles eq "reseller") && $c->user->read_only);
my $form = NGCP::Panel::Form::Subscriber::EditWebpass->new;
my $posted = ($c->request->method eq 'POST');
$form->process(
posted => $posted,
params => $c->request->params,
);
if($posted && $form->validated) {
my $schema = $c->model('DB');
try {
my $subscriber = $c->stash->{subscriber};
my $prov_subscriber = $subscriber->provisioning_voip_subscriber;
$schema->txn_do(sub {
$prov_subscriber->update({
webpassword => $form->value->{webpassword} });
$c->flash(messages => [{type => 'success', text => $c->loc('Successfully updated password') }]);
});
} catch($e) {
NGCP::Panel::Utils::Message->error(
c => $c,
error => $e,
desc => $c->loc('Failed to update subscriber (webpassword).'),
);
}
NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for_action('/subscriber/webpass', [$c->req->captures->[0]]));
}
$c->stash(
edit_flag => 1,
form => $form,
close_target => $c->uri_for_action('/subscriber/webpass', [$c->req->captures->[0]]),
template => 'subscriber/edit_webpass.tt',
);
}
sub edit_voicebox :Chained('base') :PathPart('preferences/voicebox/edit') :Args(1) {
my ($self, $c, $attribute) = @_;

@ -0,0 +1,47 @@
package NGCP::Panel::Form::Subscriber::EditWebpass;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';
use Moose::Util::TypeConstraints;
use HTML::FormHandler::Widget::Block::Bootstrap;
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 'webpassword' => (
type => 'Text',
label => 'Web Password',
required => 1,
minlength => 6,
element_attr => {
rel => ['tooltip'],
title => ['The password to log into the CSC Panel'],
},
);
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/webpassword/ ],
);
has_block 'actions' => (
tag => 'div',
class => [qw/modal-footer/],
render_list => [qw/save/],
);
1;
# vim: set tabstop=4 expandtab:

@ -0,0 +1,77 @@
[% site_config.title = c.loc('User Details for [_1]@[_2]', subscriber.username, subscriber.domain.domain) -%]
<div class="row">
<span class="pull-left" style="margin:0 5px 0 5px;">
<a class="btn btn-primary btn-large" href="[% c.uri_for('/back') %]"><i class="icon-arrow-left"></i> [% c.loc('Back') %]</a>
<a class="btn btn-primary btn-large" href="[% c.uri_for_action('/subscriber/webpass_edit', [ subscriber.id ]) %]"><i class="icon-edit"></i> [% c.loc('Change Password') %]</a>
</span>
</div>
[% back_created = 1 -%]
<div class="row">
[% FOREACH m IN messages -%]
<div class="alert alert-[% m.type %]">[% m.text %]</div>
[% END -%]
</div>
<div class="ngcp-separator"></div>
<table class="table table-bordered table-striped table-highlight table-hover" id="subscribers_table">
<thead>
<tr>
<th>[% c.loc('Setting') %]</th>
<th>[% c.loc('Values') %]</th>
</tr>
</thead>
<tbody>
[% IF c.user.roles == "admin" || c.user.roles == "reseller" -%]
<tr class="sw_action_row">
<td>[% c.loc('Customer #') %]</td>
<td>[% subscriber.contract.id %]</td>
</tr>
[% END;
elements = [];
elements.push({ value = subscriber.provisioning_voip_subscriber.webusername, desc = c.loc('Web Username') });
elements.push({ value = '******', desc = c.loc('Web Password') });
elements.push({ value = subscriber.username _ '@' _ subscriber.domain.domain, desc = c.loc('SIP URI') });
#elements.push({ value = , desc = c.loc('Primary Number') });
-%]
[% FOR elem IN elements -%]
<tr>
<td>[% elem.desc %]</td>
<td>[% elem.value %]</td>
</tr>
[% END -%]
<tr>
<td>[% c.loc('Numbers') %]</td>
<td>
[% FOR num IN subscriber.voip_numbers.all -%]
[% num.cc %] [% num.ac %] [% num.sn %]<br/>
[% END -%]
</td>
</tr>
</tbody>
</table>
[% IF edit_flag == 1 -%]
<!-- edit master data -->
[%
IF form.has_for_js;
form.render_repeatable_js;
END;
PROCESS "helpers/modal.tt";
modal_header(m.create_flag=0,
m.name = description);
form = translate_form(form);
form.render;
modal_footer();
modal_script(m.close_target = close_target);
-%]
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

@ -9,6 +9,7 @@
<li><a href="[% c.uri_for_action('/subscriber/voicemails', [subscriber.id]) %]">[% c.loc('Voicebox Messages') %]</a></li>
<li><a href="[% c.uri_for_action('/subscriber/reglist', [subscriber.id]) %]">[% c.loc('Registered Devices') %]</a></li>
<li><a href="[% c.uri_for_action('/subscriber/preferences', [subscriber.id]) %]">[% c.loc('Line Settings') %]</a></li>
<li><a href="[% c.uri_for_action('/subscriber/webpass', [subscriber.id]) %]">[% c.loc('User Details') %]</a></li>
</ul>
</li>
[% # vim: set tabstop=4 syntax=html expandtab: -%]

Loading…
Cancel
Save