1 package FS::ClientAPI::passwd;
4 use FS::Record qw(qsearchs);
11 my $domain = $FS::ClientAPI::domain || $packet->{'domain'};
12 my $svc_domain = qsearchs('svc_domain', { 'domain' => $domain } )
13 or return { error => "Domain $domain not found" };
15 my $old_password = $packet->{'old_password'};
16 my $new_password = $packet->{'new_password'};
17 my $new_gecos = $packet->{'new_gecos'};
18 my $new_shell = $packet->{'new_shell'};
20 #false laziness w/FS::ClientAPI::MyAccount::login
22 my $svc_acct = qsearchs( 'svc_acct', { 'username' => $packet->{'username'},
23 'domsvc' => $svc_domain->svcnum, }
25 return { error => 'User not found.' } unless $svc_acct;
26 return { error => 'Incorrect password.' }
27 unless $svc_acct->check_password($old_password);
29 my %hash = $svc_acct->hash;
30 my $new_svc_acct = new FS::svc_acct ( \%hash );
31 $new_svc_acct->setfield('_password', $new_password )
32 if $new_password && $new_password ne $old_password;
33 $new_svc_acct->setfield('finger',$new_gecos) if $new_gecos;
34 $new_svc_acct->setfield('shell',$new_shell) if $new_shell;
35 my $error = $new_svc_acct->replace($svc_acct);
37 return { error => $error };