diff options
Diffstat (limited to 'Bugzilla/Auth.pm')
-rw-r--r-- | Bugzilla/Auth.pm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Bugzilla/Auth.pm b/Bugzilla/Auth.pm index 45034e166..2c58b52a8 100644 --- a/Bugzilla/Auth.pm +++ b/Bugzilla/Auth.pm @@ -38,6 +38,7 @@ use Bugzilla::User::Setting (); use Bugzilla::Auth::Login::Stack; use Bugzilla::Auth::Verify::Stack; use Bugzilla::Auth::Persist::Cookie; +use Socket; sub new { my ($class, $params) = @_; @@ -123,6 +124,15 @@ sub can_logout { return $getter->can_logout; } +sub login_token { + my ($self) = @_; + my $getter = $self->{_info_getter}->{successful}; + if ($getter && $getter->isa('Bugzilla::Auth::Login::Cookie')) { + return $getter->login_token; + } + return undef; +} + sub user_can_create_account { my ($self) = @_; my $verifier = $self->{_verifier}->{successful}; @@ -215,10 +225,19 @@ sub _handle_login_result { my $default_settings = Bugzilla::User::Setting::get_defaults(); my $template = Bugzilla->template_inner( $default_settings->{lang}->{default_value}); + my $address = $attempts->[0]->{ip_addr}; + # Note: inet_aton will only resolve IPv4 addresses. + # For IPv6 we'll need to use inet_pton which requires Perl 5.12. + my $n = inet_aton($address); + if ($n) { + my $host = gethostbyaddr($n, AF_INET); + $address = "$host ($address)" if $host; + } my $vars = { locked_user => $user, attempts => $attempts, unlock_at => $unlock_at, + address => $address, }; my $message; $template->process('email/lockout.txt.tmpl', $vars, \$message) @@ -416,6 +435,14 @@ Params: None Returns: C<true> if users can change their own email address, C<false> otherwise. +=item C<login_token> + +Description: If a login token was used instead of a cookie then this + will return the current login token data such as user id + and the token itself. +Params: None +Returns: A hash containing C<login_token> and C<user_id>. + =back =head1 STRUCTURE |