Skip to content

Commit

Permalink
Temp local version of PassphraseColumn
Browse files Browse the repository at this point in the history
Switched from DBIx::Class::PassphraseColumn to local copy
RapidApp::DBIC::Component::PassphraseColumn which includes the null
column fix from
rafl/dbix-class-passphrasecolumn#3.

**This is just temporary until the CPAN version includes the fix. Will
go back to the real/correct version as soon as that happens.

(set dev ver 1.3103_01)
  • Loading branch information
vanstyn committed May 25, 2019
1 parent 09d2e49 commit 5f718cf
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ license = Perl_5
copyright_holder = IntelliTree Solutions llc
copyright_year = 2013

version = 1.3103
version = 1.3103_01

[MetaResources]
homepage = http://www.rapidapp.info
Expand Down Expand Up @@ -78,6 +78,7 @@ SQL::Translator = 0.11021
SQL::Abstract = 1.81
DateTime::Format::SQLite = 0.11
DBD::SQLite = 1.42
DBIx::Class::InflateColumn::Authen::Passphrase = 0.01

Catalyst::Authentication::Store::DBIx::Class = 0.1506

Expand Down
2 changes: 1 addition & 1 deletion lib/RapidApp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;
# Min supported Perl is currently v5.10
use 5.010;

our $VERSION = 1.3103;
our $VERSION = 1.3103_01;

# ABSTRACT: Turnkey ajaxy webapps

Expand Down
9 changes: 7 additions & 2 deletions lib/RapidApp/CoreSchema/Result/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ use MooseX::NonMoose;
use namespace::autoclean;
extends 'DBIx::Class::Core';

use DBIx::Class::PassphraseColumn 0.02;
#use DBIx::Class::PassphraseColumn 0.02;
use RapidApp::DBIC::Component::PassphraseColumn; # temp

__PACKAGE__->load_components("InflateColumn::DateTime","PassphraseColumn");
__PACKAGE__->load_components(
"InflateColumn::DateTime",
#"PassphraseColumn",
'+RapidApp::DBIC::Component::PassphraseColumn'
);

__PACKAGE__->table('user');

Expand Down
91 changes: 91 additions & 0 deletions lib/RapidApp/DBIC/Component/PassphraseColumn.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
use strict;
use warnings;

package # hide from PAUSE
RapidApp::DBIC::Component::PassphraseColumn;

# Temp copy of DBIx::Class::PassphraseColumn with fix for null columns.
# will stop using this as soon as the real module merges that fix
# https://github.com/rafl/dbix-class-passphrasecolumn/pull/3

use Class::Load 'load_class';
use Sub::Name 'subname';
use namespace::clean;

use parent 'DBIx::Class';


__PACKAGE__->load_components(qw(InflateColumn::Authen::Passphrase));

__PACKAGE__->mk_classdata('_passphrase_columns');

sub register_column {
my ($self, $column, $info, @rest) = @_;

if (my $encoding = $info->{passphrase}) {
$info->{inflate_passphrase} = $encoding;

$self->throw_exception(q['passphrase_class' is a required argument])
unless exists $info->{passphrase_class}
&& defined $info->{passphrase_class};

my $class = 'Authen::Passphrase::' . $info->{passphrase_class};
load_class $class;

my $args = $info->{passphrase_args} || {};
$self->throw_exception(q['passphrase_args' must be a hash reference])
unless ref $args eq 'HASH';

my $encoder = sub {
my ($val) = @_;
$class->new(%{ $args }, passphrase => $val)->${\"as_${encoding}"};
};

$self->_passphrase_columns({
%{ $self->_passphrase_columns || {} },
$column => $encoder,
});

if (defined(my $meth = $info->{passphrase_check_method})) {
my $checker = sub {
my ($row, $val) = @_;
my $ppr = $row->get_inflated_column($column) or return 0;
return $ppr->match($val);
};

my $name = join q[::] => $self->result_class, $meth;

{
no strict 'refs';
*$name = subname $name => $checker;
}
}
}

$self->next::method($column, $info, @rest);
}

sub set_column {
my ($self, $col, $val, @rest) = @_;

my $ppr_cols = $self->_passphrase_columns;
return $self->next::method($col, $ppr_cols->{$col}->($val), @rest)
if exists $ppr_cols->{$col};

return $self->next::method($col, $val, @rest);
}

sub new {
my ($self, $attr, @rest) = @_;

my $ppr_cols = $self->_passphrase_columns;
for my $col (keys %{ $ppr_cols }) {
next unless exists $attr->{$col} && !ref $attr->{$col};
$attr->{$col} = $ppr_cols->{$col}->( $attr->{$col} );
}

return $self->next::method($attr, @rest);
}


1;

0 comments on commit 5f718cf

Please sign in to comment.