= 0; $POST{'bindip'} = 'yes' if index($&, "<") >= 0; } my $user = LJ::canonical_username($POST{'user'}); my $password = $POST{'password'}; my $remote = LJ::get_remote(); my $cursess = $remote ? $remote->session : undef; my $form_auth_ok = LJ::did_post() && LJ::check_form_auth(); my $old_remote = $remote; $title = $remote ? BML::ml(".loggedin.head2", { 'sitename' => $LJ::SITENAMESHORT} ) : BML::ml(".login.title", { 'sitename' => $LJ::SITENAMESHORT} ); # we may want to redirect later in failed cases, based on this ugly blob of logic # return 1 if $want_fail_redirect is handling the request, otherwise 0 and the caller should handle # @error_codes is a list of error codes that should be added to the redirect URL. my $want_fail_redirect = sub { my @error_codes = @_; if ($POST{ret_fail} && $POST{ret_fail} =~ m!^http://([\.:\w-]+)!i && $LJ::REDIRECT_ALLOWED{$1}) { BML::redirect($POST{ret_fail} . LJ::eurl(join(',', @error_codes))); return 1; } return 0; }; # we may want to redirect later in successfull cases, based on this ugly blob of logic # return 1 if $want_success_redirect is handling the request, otherwise 0 and the caller should handle my $want_success_redirect = sub { if ($POST{returnto}) { # this passes in the URI of the page to redirect to on success, eg: # /manage/profile/index.bml?authas=test or whatever my $uri = $POST{returnto}; if ($uri =~ /^\//) { $uri = $LJ::SITEROOT . $uri; } BML::redirect($uri); return 1; } # Redirect to offsite uri if allowed, and not an internal LJ redirect. ('ret' == 1) if ($POST{ret} && $POST{ret} != 1) { my $redir_host = $1 if $POST{ret} =~ m#^http://([\.:\w-]+)#i; # if the redirect is going to FotoBilder, and they don't have the fb_account cap, # then we don't redirect them, but keep them here and display an error message my $u = LJ::load_user($user); if ($redir_host =~ /$LJ::FB_DOMAIN/ && ! LJ::get_cap($u, 'fb_account')) { return 1 if $want_fail_redirect->("fotobilder_denied"); $body = LJ::bad_input("Your account type does not allow logins to remote FotoBilder sites"); return 1; } if ($LJ::REDIRECT_ALLOWED{$redir_host} || $redir_host eq $LJ::DOMAIN_WEB) { LJ::run_hook('login_redirect_extra', $redir_host); BML::redirect($POST{ret}); return 1; } } return 0; }; if ($remote && $remote->readonly) { return if $want_fail_redirect->("database_readonly"); $body = LJ::bad_input("The database is temporarily in read-only mode, so creating new login sessions is temporarily down. Please try again later."); return; } my $require_tos = 0; my $login_html = sub { my $nojs = $GET{'nojs'}; # can't do challenge/response with LDAP. $nojs = 1 if $LJ::LDAP_HOST; my $getextra = $nojs ? '?nojs=1' : ''; if (@errors) { return if $want_fail_redirect->(map {$_->[0]} @errors); $body .= "
| ";
if ($require_tos) {
my $err_code = (ref $require_tos eq 'HASH') ? $require_tos->{code} : 'tos_required';
return if $want_fail_redirect->($err_code);
$body .= " ";
my $tos_err = ref $require_tos eq 'HASH' ? $require_tos->{err} : undef;
$body .= LJ::tosagree_html('login', $POST{agree_tos}, $tos_err);
$body .= " ";
}
if ($remote) {
my $base = $remote->journal_base;
$body .= " LJ::ljuser($remote)} ) . " p?>\n";
if ($remote->is_identity && !$remote->is_validated) {
$body .= " "href='$LJ::SITEROOT/changeemail.bml'", aopts2 => "href='$LJ::SITEROOT/register.bml'" }) . " warningbar?>";
}
$body .= "\n"; $body .= " ";
$body .= " \n";
$body .= "![]() ";
$body .= "";
$body .= "$ML{'.loggedin.suggesthead1'} h2?>\n";
$body .= "$ML{'.loggedin.suggest1'} \n";
$body .= "";
$body .= " \n";
$body .= "![]() ";
$body .= "";
$body .= "$ML{'.loggedin.suggesthead2'} h2?>\n";
$body .= "$ML{'.loggedin.suggest2'} \n";
$body .= "\n"; $body .= "\n"; } else { $body .= " \n";
$body .= " \n";
$body .= LJ::Widget::Login->render( get_ret => $GET{ret}, post_ret => $POST{ret},
returnto => $POST{returnto}, nojs => $nojs, user => $user );
$body .= " \n";
$body .= "\n";
$body .= " \n";
$body .= "\n"; $body .= " $ML{'.createaccount.header'}\n"; $body .= "\n"; $body .= "
\n";
$body .= LJ::get_ads({ location => 'bml.login' }) unless $LJ::IS_SSL;
$body .= " \n";
}
$body .= " | \n";
if ($remote) {
my $box = LJ::CProd->full_box_for($remote, width => 300);
# because post_login_news is really post_login_ad in ljcom ....
# unfortunate hook name :/
if (!$box || LJ::run_hook('should_show_ad', { ctx => "app", })) {
$body .= LJ::run_hook('post_login_news');
$body .= " \n"; } $body .= $box; } $body .= " |