Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- === Changes
- ==================================================================
- --- Changes (revision 18123)
- +++ Changes (local)
- @@ -1,5 +1,7 @@
- Revision history for Perl extension Catalyst::Plugin::Authentication::Store::DBIC
- + - Made $c->user->id return the first field of user_field, rather than whatever was passed in.
- +
- 0.07 2006-06-30 01:08:47
- - make the User class stringify to the user id
- - documentation fixes
- === lib/Catalyst/Plugin/Authentication/Store/DBIC/Backend.pm
- ==================================================================
- --- lib/Catalyst/Plugin/Authentication/Store/DBIC/Backend.pm (revision 18123)
- +++ lib/Catalyst/Plugin/Authentication/Store/DBIC/Backend.pm (local)
- @@ -24,19 +24,20 @@
- return $id if ref $id;
- - # XXX: hits the database on every request? Not good...
- - return $self->get_user( $id );
- +
- + return $self->{auth}{catalyst_user_class}->new( $id, { %{$self} } );
- +
- }
- sub get_user {
- my ( $self, $id, @rest ) = @_;
- my $user = $self->{auth}{catalyst_user_class}->new( $id, { %{$self} } );
- + $user->id($user->canonical_id);
- if ( $user ) {
- $user->store( $self );
- $user->obj->auto_update( $id, @rest ) if $self->{auth}{auto_update_user};
- - return $user;
- } elsif ( $self->{auth}{auto_create_user} ) {
- $self->{auth}{user_class}->auto_create( $id, @rest ) and return $self->get_user( $id );
- }
- === lib/Catalyst/Plugin/Authentication/Store/DBIC/User.pm
- ==================================================================
- --- lib/Catalyst/Plugin/Authentication/Store/DBIC/User.pm (revision 18123)
- +++ lib/Catalyst/Plugin/Authentication/Store/DBIC/User.pm (local)
- @@ -7,25 +7,34 @@
- use overload '""' => sub { shift->id }, 'bool' => sub { 1 }, fallback => 1;
- -__PACKAGE__->mk_accessors(qw/id config obj store/);
- +__PACKAGE__->mk_accessors(qw/id config store/);
- +
- sub new {
- my ( $class, $id, $config ) = @_;
- + bless {
- + id => $id,
- + config => $config
- + }, $class;
- +}
- +sub obj {
- + my $self=shift;
- + my $config=$self->config;
- + my $id=$self->id;
- my $query = @{$config->{auth}{user_field}} > 1
- ? { -or => [ map { { $_ => $id } } @{$config->{auth}{user_field}} ] }
- : { $config->{auth}{user_field}[0] => $id };
- - my $user_obj = $config->{auth}{user_class}->search($query)->first;
- - return unless $user_obj;
- + return $config->{auth}{user_class}->search($query)->first;
- +}
- - bless {
- - id => $id,
- - config => $config,
- - obj => $user_obj,
- - }, $class;
- +sub canonical_id {
- + my $self=shift;
- + return $self->obj->get_column($self->config->{auth}{user_field}[0]),
- }
- +
- *user = \&obj;
- *crypted_password = \&password;
- *hashed_password = \&password;
Add Comment
Please, Sign In to add comment