1 % if ( $cgi->param('_password') ne $cgi->param('_password2') ) {
2 % $cgi->param('error', "The passwords do not match");
3 % print $cgi->redirect(popurl(2) . "access_user.html?" . $cgi->query_string);
5 <% include( 'elements/process.html',
6 'table' => 'access_user',
7 'viewall_dir' => 'browse',
8 'copy_on_empty' => [ '_password', '_password_encoding' ],
9 'clear_on_error' => [ '_password', '_password2' ],
10 'process_m2m' => { 'link_table' => 'access_usergroup',
11 'target_table' => 'access_group',
13 'precheck_callback' => \&precheck_callback,
14 'post_new_object_callback' => \&post_new_object_callback,
15 'noerror_callback' => \&noerror_callback,
22 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
24 if ( FS::Conf->new->exists('disable_acl_changes') ) {
25 errorpage('ACL changes disabled in public demo.');
26 die "shouldn't be reached";
29 sub precheck_callback {
32 my $o = FS::access_user->new({username => scalar($cgi->param('username'))});
33 if( $o->is_system_user and !$cgi->param('usernum') ) {
34 $cgi->param('username','');
35 return "username '".$o->username."' reserved for system account."
41 sub post_new_object_callback {
42 my( $cgi, $access_user ) = @_;
44 return '' unless length($cgi->param('_password'));
46 my $password = scalar($cgi->param('_password'));
47 my $error = $access_user->is_password_allowed($password);
48 return $error if $error;
50 $access_user->change_password_fields($password);
54 sub noerror_callback {
55 my( $cgi, $access_user ) = @_;
57 #handle installer checkbox
58 my @sched_item = $access_user->sched_item;
59 my $sched_item = $sched_item[0];
60 if ( $cgi->param('sched_item_enabled') ) {
62 if ( ! $sched_item ) {
63 my $sched_item = new FS::sched_item {
64 'usernum' => $access_user->usernum,
66 my $error = $sched_item->insert;
67 die $error if $error; #wtf? shouldn't happen
68 } elsif ( $sched_item->disabled ) {
69 $sched_item->disabled('');
70 my $error = $sched_item->replace;
71 die $error if $error; #wtf? shouldn't happen
74 } elsif ( ! $cgi->param('sched_item_enabled')
76 && ! $sched_item->disabled
79 $sched_item->disabled('Y');
80 my $error = $sched_item->replace;
81 die $error if $error; #wtf? shouldn't happen