} );
}
+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;
sub check_pin {
my($self, $check_pin) = @_;
- $check_pin eq $self->pin;
+ length($self->pin) && $check_pin eq $self->pin;
}
=item radius_reply
'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',
'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';
}
$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:
<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>
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
$cgi = new CGI;
unless ( defined $cgi->param('session') ) {
- do_template('login',{});
+ my $login_info = login_info();
+
+ do_template('login', $login_info );
exit;
}
'password' => $password,
);
if ( $rv->{error} ) {
+ my $login_info = login_info();
do_template('login', {
'error' => $rv->{error},
'username' => $username,
'domain' => $domain,
+ %$login_info,
} );
exit;
} else {
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;
}
$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