diff options
-rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 14 | ||||
-rw-r--r-- | FS/FS/svc_phone.pm | 2 | ||||
-rw-r--r-- | fs_selfservice/FS-SelfService/SelfService.pm | 50 | ||||
-rw-r--r-- | fs_selfservice/FS-SelfService/cgi/login.html | 76 | ||||
-rw-r--r-- | fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 23 |
5 files changed, 136 insertions, 29 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 114a359b7..e15476153 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -55,6 +55,20 @@ sub _cache { } ); } +sub login_info { + my $p = shift; + + my $conf = new FS::Conf; + + my %info = ( + 'phone_login' => $conf->exists('selfservice_server-phone_login'), + 'single_domain'=> scalar($conf->config('selfservice_server-single_domain')), + ); + + return \%info; + +} + #false laziness w/FS::ClientAPI::passwd::passwd sub login { my $p = shift; diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index 237bbf5c7..5dcb39ef8 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -224,7 +224,7 @@ sucessful authentication, false if no match. sub check_pin { my($self, $check_pin) = @_; - $check_pin eq $self->pin; + length($self->pin) && $check_pin eq $self->pin; } =item radius_reply diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index cba85e0db..56c96f61b 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -25,6 +25,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'passwd' => 'passwd/passwd', 'chfn' => 'passwd/passwd', 'chsh' => 'passwd/passwd', + 'login_info' => 'MyAccount/login_info', 'login' => 'MyAccount/login', 'logout' => 'MyAccount/logout', 'customer_info' => 'MyAccount/customer_info', @@ -63,7 +64,11 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'call_time_nanpa' => 'PrepaidPhone/call_time_nanpa', 'phonenum_balance' => 'PrepaidPhone/phonenum_balance', ); -@EXPORT_OK = ( keys(%autoload), qw( regionselector expselect popselector domainselector didselector) ); +@EXPORT_OK = ( + keys(%autoload), + qw( regionselector regionselector_hashref + expselect popselector domainselector didselector ) +); $ENV{'PATH'} ='/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; @@ -1189,24 +1194,45 @@ END } $state_html .= '</SELECT>'; - $state_html .= '</SELECT>'; + my $country_html = ''; + if ( scalar( keys %cust_main_county ) > 1 ) { + + $country_html = qq(<SELECT NAME="${prefix}country" ). + qq(onChange="${prefix}country_changed(this); ). + $param->{'onchange'}. + '"'. + '>'; + my $countrydefault = $param->{default_country} || 'US'; + foreach my $country ( + sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) or $a cmp $b } + keys %cust_main_county + ) { + my $selected = $country eq $param->{'selected_country'} + ? ' SELECTED' + : ''; + $country_html .= "\n<OPTION$selected>$country</OPTION>" + } + $country_html .= '</SELECT>'; + } else { + + $country_html = qq(<INPUT TYPE="hidden" NAME="${prefix}country" ). + ' VALUE="'. (keys %cust_main_county )[0]. '">'; - my $country_html = qq!<SELECT NAME="${prefix}country" !. - qq!onChange="${prefix}country_changed(this); $param->{'onchange'}">!; - my $countrydefault = $param->{default_country} || 'US'; - foreach my $country ( - sort { ($b eq $countrydefault) <=> ($a eq $countrydefault) or $a cmp $b } - keys %cust_main_county - ) { - my $selected = $country eq $param->{'selected_country'} ? ' SELECTED' : ''; - $country_html .= "\n<OPTION$selected>$country</OPTION>" } - $country_html .= '</SELECT>'; ($county_html, $state_html, $country_html); } +sub regionselector_hashref { + my ($county_html, $state_html, $country_html) = regionselector(@_); + { + 'county_html' => $county_html, + 'state_html' => $state_html, + 'country_html' => $country_html, + }; +} + #=item expselect HASHREF | LIST # #Takes as input a hashref or list of key/value pairs with the following keys: diff --git a/fs_selfservice/FS-SelfService/cgi/login.html b/fs_selfservice/FS-SelfService/cgi/login.html index 5607de783..e5daec859 100644 --- a/fs_selfservice/FS-SelfService/cgi/login.html +++ b/fs_selfservice/FS-SelfService/cgi/login.html @@ -1,29 +1,85 @@ <HTML><HEAD><TITLE>Login</TITLE></HEAD> <BODY BGCOLOR="#e8e8e8"><FONT SIZE=5>Login</FONT><BR><BR> <FONT SIZE="+1" COLOR="#ff0000"><%= $error %></FONT> + <FORM ACTION="<%= $self_url %>" METHOD=POST> <INPUT TYPE="hidden" NAME="session" VALUE="login"> + <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0> + <TR> <TH ALIGN="right">Username </TH> <TD> - <INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"> - </TD> -</TR> -<TR> - <TH ALIGN="right">Domain </TH> - <TD> - <INPUT TYPE="text" NAME="domain" VALUE="<%= $domain %>"> + <INPUT TYPE="text" NAME="username" VALUE="<%= $username %>"><%= $single_domain ? '@'.$single_domain : '' %> </TD> </TR> -<!--<INPUT TYPE="hidden" NAME="domain" VALUE="myisp.com">--> + +<%= +if ( $single_domain ) { + + $OUT .= qq(<INPUT TYPE="hidden" NAME="domain" VALUE="$single_domain">); + +} else { + + $OUT .= qq( + <TR> + <TH ALIGN="right">Domain </TH> + <TD> + <INPUT TYPE="text" NAME="domain" VALUE="$domain"> + </TD> + </TR> + ); + +} + +%> + <TR> <TH ALIGN="right">Password </TH> <TD> <INPUT TYPE="password" NAME="password"> </TD> </TR> +<TR> + <TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" VALUE="Login"></TD> +</TR> </TABLE> -<BR><BR><INPUT TYPE="submit" VALUE="Login"> -</FORM></BODY></HTML> +</FORM> + +<%= + +if ( $phone_login ) { + + $OUT .= qq( + + <B>OR</B><BR><BR> + + <FORM ACTION="$self_url" METHOD=POST> + <INPUT TYPE="hidden" NAME="session" VALUE="login"> + <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0> + <TR> + <TH ALIGN="right">Phone number </TH> + <TD> + <INPUT TYPE="text" NAME="username" VALUE="$username"> + </TD> + </TR> + <INPUT TYPE="hidden" NAME="domain" VALUE="svc_phone"> + <TR> + <TH ALIGN="right">PIN </TH> + <TD> + <INPUT TYPE="password" NAME="password"> + </TD> + </TR> + <TR> + <TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" VALUE="Login"></TD> + </TR> + </TABLE> + </FORM> + + ); + +} + +%> +</BODY></HTML> diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 539877bf2..cd81aeb8d 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -9,7 +9,7 @@ use Text::Template; use HTML::Entities; use Date::Format; use Number::Format 1.50; -use FS::SelfService qw( login customer_info edit_info invoice +use FS::SelfService qw( login_info login customer_info edit_info invoice payment_info process_payment process_prepay list_pkgs order_pkg signup_info order_recharge @@ -28,7 +28,9 @@ $form_max = 255; $cgi = new CGI; unless ( defined $cgi->param('session') ) { - do_template('login',{}); + my $login_info = login_info(); + + do_template('login', $login_info ); exit; } @@ -52,10 +54,12 @@ if ( $cgi->param('session') eq 'login' ) { 'password' => $password, ); if ( $rv->{error} ) { + my $login_info = login_info(); do_template('login', { 'error' => $rv->{error}, 'username' => $username, 'domain' => $domain, + %$login_info, } ); exit; } else { @@ -81,7 +85,10 @@ die $@ if $@; if ( $result->{error} eq "Can't resume session" || $result->{error} eq "Expired session" ) { #ick - do_template('login',{}); + my $login_info = login_info(); + use Data::Dumper; + warn Dumper($login_info); + do_template('login', $login_info); exit; } @@ -620,12 +627,16 @@ sub do_template { $fill_in->{'selfurl'} = $cgi->self_url; $fill_in->{'cgi'} = \$cgi; - my $template = new Text::Template( TYPE => 'FILE', - SOURCE => "$template_dir/$name.html", + my $source = "$template_dir/$name.html"; + #warn "creating template for $source\n"; + my $template = new Text::Template( TYPE => 'FILE', + SOURCE => $source, DELIMITERS => [ '<%=', '%>' ], - UNTAINT => 1, ) + UNTAINT => 1, + ) or die $Text::Template::ERROR; + #warn "filling in $template with $fill_in\n"; print $cgi->header( '-expires' => 'now' ), $template->fill_in( PACKAGE => 'FS::SelfService::_selfservicecgi', HASH => $fill_in |