| 1 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Interchange6::Schema::ResultSet::User; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Interchange6::Schema::ResultSet::User | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =cut | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Provides extra accessor methods for L<Interchange6::Schema::Result::User> | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =cut | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use parent 'Interchange6::Schema::ResultSet'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head1 METHODS | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head2 find | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | Override L<DBIx::Class::ResultSet/find> for lookup of | ||||||||||||||||||||||||||||
| 28 | L<Interchange6::Schema::Result::User/username> so that leading/trailing spaces | ||||||||||||||||||||||||||||
| 29 | are stripped from username and it is also lower-cased. | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub find { | ||||||||||||||||||||||||||||
| 34 | 29 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
find: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 29 | ▶ | if ( ref( $_[0] ) eq 'HASH' && defined $_[0]->{username} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $_[0] eq "HASH" and defined $_[0]{"username"}
MC/DC100%2/2
ref $_[0] eq "HASH" and defined $_[0]{"username"}
ref $_[0] eq "HASH"
defined $_[0]{"username"}
Truth table100%3/3
A and B
A= ref $_[0] eq "HASH"B= defined $_[0]{"username"}
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # looking for a username | ||||||||||||||||||||||||||||
| 39 | 25 | $_[0]->{username} = lc( $_[0]->{username} ); | |||||||||||||||||||||||||||
| 40 | 25 | $_[0]->{username} =~ s/(^\s+|\s+$)//g; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 29 | $self->next::method(@_); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =head2 find_user_with_reset_token( $token ); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Where $token is the combined <Interchange6::Schema::Result::User/reset_token> | ||||||||||||||||||||||||||||
| 49 | and <Interchange6::Schema::Result::User/reset_token_checksum> as would be | ||||||||||||||||||||||||||||
| 50 | returned by <Interchange6::Schema::Result::User/reset_token_generate>. | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | Returns an <Interchange6::Schema::Result::User> object if $token is found and | ||||||||||||||||||||||||||||
| 53 | is valid. On failure returns undef. | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =cut | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | sub find_user_with_reset_token { | ||||||||||||||||||||||||||||
| 58 | 10 | ▶ | my ( $self, $arg ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
find_user_with_reset_token: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 10 | ▶ | $self->throw_exception("Bad argument to find_user_with_reset_token") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | unless $arg; | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 9 | my ( $token, $checksum ) = split(/_/, $arg); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 9 | ▶ | $self->throw_exception("Bad argument to find_user_with_reset_token") | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token and $checksum
MC/DC100%2/2
$token and $checksum
$token
$checksum
Truth table100%3/3
A and B
A= $tokenB= $checksum
| |||||||||||||||||||||||||||||
| 66 | unless ( $token && $checksum ); | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 5 | my $users = $self->search({reset_token => $token}); | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 5 | ▶ | while ( my $user = $users->next ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 4 | ▶ | return $user if $user->reset_token_verify( $arg ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 3 | return undef; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 2 | 1; | |||||||||||||||||||||||||||