$cgi->param($_, FS::UI::bytecount::parse_bytecount($cgi->param($_)) );
}
+#unmunge cgp_accessmodes (falze laziness-ish w/part_svc.pm::process &svc_domain)
+unless ( $cgi->param('cgp_accessmodes') ) {
+ $cgi->param('cgp_accessmodes',
+ join(' ',
+ sort map { /^cgp_accessmodes_([\w\/]+)$/ or die "no way"; $1; }
+ grep $cgi->param($_),
+ grep /^cgp_accessmodes_([\w\/]+)$/,
+ $cgi->param()
+ )
+ );
+}
+
my %hash = $svcnum ? $old->hash : ();
-map {
+for ( fields('svc_acct'), qw( pkgnum svcpart usergroup ) ) {
$hash{$_} = scalar($cgi->param($_));
- #} qw(svcnum pkgnum svcpart username _password popnum uid gid finger dir
- # shell quota slipip)
- } (fields('svc_acct'), qw ( pkgnum svcpart usergroup ));
+}
+if ( $svcnum ) {
+ for ( grep $old->$_, qw( cf_privatekey ) ) {
+ $hash{$_} = $old->$_;
+ }
+}
my $new = new FS::svc_acct ( \%hash );
+my $error = '';
+
+# google captcha auth
+if ( $cgi->param('captcha_response') ) {
+ my $part_svc = $svcnum ?
+ $old->part_svc :
+ qsearchs( 'part_svc',
+ { 'svcpart' => $cgi->param('svcpart') }
+ );
+ my ($export) = $part_svc->part_export('acct_google');
+ if ( $export and
+ ! $export->captcha_auth($cgi->param('captcha_response')) ) {
+ $error = 'Re-enter the security word.';
+ }
+}
+
$new->_password($old->_password) if $old;
-if( $cgi->param('clear_password') eq '*HIDDEN*'
- or $cgi->param('clear_password') =~ /^\(.* encrypted\)$/ ) {
+if ( $cgi->param('clear_password') eq '*HIDDEN*'
+ || $cgi->param('clear_password') =~ /^\(.* encrypted\)$/ ) {
die "fatal: no previous account to recall hidden password from!" unless $old;
-}
-else {
- $new->set_password($cgi->param('clear_password'));
+} else {
+ $error ||= $new->set_password($cgi->param('clear_password'));
}
-my $error;
-if ( $svcnum ) {
- foreach (grep { $old->$_ != $new->$_ } qw( seconds upbytes downbytes totalbytes )) {
- my %hash = map { $_ => $new->$_ }
- grep { $new->$_ }
- qw( seconds upbytes downbytes totalbytes );
+if ( ! $error ) {
+ if ( $svcnum ) {
+ foreach ( grep { $old->$_ != $new->$_ }
+ qw( seconds upbytes downbytes totalbytes )
+ )
+ {
+ my %hash = map { $_ => $new->$_ }
+ grep { $new->$_ }
+ qw( seconds upbytes downbytes totalbytes );
- $error = $new->set_usage(\%hash); #unoverlimit and trigger radius changes
- last; #once is enough
+ $error ||= "invalid $_" foreach grep { $hash{$_} !~ /^-?\d+$/ } keys %hash;
+ $error ||= $new->set_usage(\%hash); #unoverlimit and trigger radius changes
+ last; #once is enough
+ }
+ $error ||= $new->replace($old);
+ } else {
+ $error ||= $new->insert;
+ $svcnum = $new->svcnum;
}
- $error ||= $new->replace($old);
-} else {
- $error = $new->insert;
- $svcnum = $new->svcnum;
}
</%init>