Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 5.57 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/dev/mojo-user-auth/catalyst/Build.PL b/dev/mojo-user-auth/catalyst/Build.PL
  2. index 5be4ad5..8f37367 100644
  3. --- a/dev/mojo-user-auth/catalyst/Build.PL
  4. +++ b/dev/mojo-user-auth/catalyst/Build.PL
  5. @@ -19,21 +19,30 @@ my $build = Test::Run::Builder->new(
  6.      },
  7.      requires =>
  8.      {
  9. -        'Catalyst::Runtime' => '5.80022',
  10.          'Catalyst::Action::RenderView' => 0,
  11. +        'Catalyst::Authentication::Store::DBIx::Class' => 0,
  12. +        'Catalyst::Controller::HTML::FormFu' => 0,
  13.          'Catalyst::Plugin::Authentication' => '0.03',
  14. +        'Catalyst::Plugin::Authorization::Roles' => 0,
  15.          'Catalyst::Plugin::ConfigLoader' => 0,
  16. -        'Catalyst::Plugin::Static::Simple' => 0,
  17.          'Catalyst::Plugin::Session' => 0,
  18. -        'Catalyst::Plugin::Session::Store::FastMmap' => 0,
  19.          'Catalyst::Plugin::Session::State::Cookie' => 0,
  20. -        'Catalyst::Plugin::Authorization::Roles' => 0,
  21. +        'Catalyst::Plugin::Session::Store::FastMmap' => 0,
  22.          'Catalyst::Plugin::StackTrace' => 0,
  23. -        'Catalyst::Authentication::Store::DBIx::Class' => 0,
  24. +        'Catalyst::Plugin::Static::Simple' => 0,
  25. +        'Catalyst::Runtime' => '5.80022',
  26.          'Catalyst::View::TT' => 0,
  27. -        'Catalyst::Controller::HTML::FormFu' => 0,
  28. +        'CGI' => 0,
  29.          'Digest' => 0,
  30. +        'Email::Sender::Simple' => 0,
  31. +        'Email::Simple' => 0,
  32. +        'Email::Simple::Creator' => 0,
  33.          'HTML::Scrubber' => 0.08,
  34. +        'KiokuDB' => 0,
  35. +        'KiokuX::User' => 0,
  36. +        'KiokuX::User::Util' => 0,
  37. +        'Moose' => 0,
  38. +        'URI::Escape' => 0,
  39.          'YAML' => 0,
  40.      },
  41.      license => "mit",
  42. diff --git a/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/App.pm b/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/App.pm
  43. index 882ee1e..624ac50 100644
  44. --- a/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/App.pm
  45. +++ b/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/App.pm
  46. @@ -367,7 +367,7 @@ sub _generic_find_user
  47.          return;
  48.      }
  49.  
  50. -    my $stream = $self->_search({email => $user_id});
  51. +    my $stream = $self->_search({id => $user_id});
  52.  
  53.      FIND_EMAIL:
  54.      while ( my $block = $stream->next )
  55. @@ -510,15 +510,17 @@ sub _send_confirmation_email
  56.      return;
  57.  }
  58.  
  59. +use KiokuX::User::Util qw(crypt_password);
  60. +
  61.  sub _register_new_user
  62.  {
  63.      my $self = shift;
  64. -  
  65. +
  66.      my $new_user = InsurgentSoftware::UserAuth::User->new(
  67.          {
  68.              fullname => $self->param("fullname"),
  69. -            password => $self->_password(),
  70. -            email => $self->_email,
  71. +            password => crypt_password($self->_password()),
  72. +            id => $self->_email,
  73.              confirm_code => $self->_get_confirm_code(),
  74.          }
  75.      );
  76. diff --git a/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/Catalyst/Controller/Auth.pm b/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/Catalyst/Controller/Auth.pm
  77. index 984df30..c43d3ec 100644
  78. --- a/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/Catalyst/Controller/Auth.pm
  79. +++ b/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/Catalyst/Controller/Auth.pm
  80. @@ -41,14 +41,6 @@ sub begin :Private {
  81.      my $dir = KiokuDB->connect(
  82.          "dbi:SQLite:dbname=./insurgent-auth.sqlite",
  83.          create => 1,
  84. -        columns =>
  85. -        [
  86. -            email =>
  87. -            {
  88. -                data_type => "varchar",
  89. -                is_nullable => 1,
  90. -            },
  91. -        ],
  92.      );
  93.  
  94.      $c->stash->{dir} = $dir;
  95. diff --git a/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/User.pm b/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/User.pm
  96. index fd38cf2..a013249 100644
  97. --- a/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/User.pm
  98. +++ b/dev/mojo-user-auth/catalyst/lib/InsurgentSoftware/UserAuth/User.pm
  99. @@ -1,12 +1,17 @@
  100.  package InsurgentSoftware::UserAuth::User;
  101.  
  102.  use Moose;
  103. +
  104. +use KiokuX::User::Util qw(crypt_password);
  105. +
  106.  use InsurgentSoftware::UserAuth::UserExtraData;
  107.  
  108.  use Crypt::SaltedHash;
  109.  
  110.  use DateTime;
  111.  
  112. +with qw(KiokuX::User);
  113. +
  114.  =head1 NAME
  115.  
  116.  InsurgentSoftware::UserAuth::User - a class representing the user-data.
  117. @@ -24,28 +29,6 @@ has fullname => (
  118.      is => "rw",
  119.  );
  120.  
  121. -=head2 $user->email()
  122. -
  123. -The email address of the user.
  124. -
  125. -=cut
  126. -
  127. -has email => (
  128. -    isa => "Str",
  129. -    is => "rw",
  130. -);
  131. -
  132. -=head2 $self->salted_password()
  133. -
  134. -The salted password.
  135. -
  136. -=cut
  137. -
  138. -has salted_password => (
  139. -    isa => "Str",
  140. -    is => "rw",
  141. -);
  142. -
  143.  =head2 $self->extra_data()
  144.  
  145.  The associated InsurgentSoftware::UserAuth::UserExtraData .
  146. @@ -126,15 +109,7 @@ sub assign_password
  147.  {
  148.      my ($self, $password) = @_;
  149.  
  150. -    my $csh = Crypt::SaltedHash->new(
  151. -        algorithm => 'SHA-256',
  152. -        salt_len => __PACKAGE__->get_salt_len(),
  153. -    );
  154. -    $csh->add($password);
  155. -
  156. -    my $salted = $csh->generate;
  157. -    
  158. -    $self->salted_password($salted);
  159. +    $self->password(crypt_password($password));
  160.  
  161.      return;
  162.  }
  163. @@ -165,19 +140,25 @@ sub verify_password
  164.      my $self = shift;
  165.      my $pass = shift;
  166.  
  167. -    return Crypt::SaltedHash->validate($self->salted_password(), $pass,
  168. -        __PACKAGE__->get_salt_len());
  169. +    return $self->check_password($pass);
  170.  }
  171.  
  172. -=head2 $self->get_salt_len()
  173. +=head2 email
  174.  
  175. -Returns the salt length for the password.
  176. +Maps to the id().
  177.  
  178.  =cut
  179.  
  180. -sub get_salt_len
  181. +sub email
  182.  {
  183. -    return 8;
  184. +    my $self = shift;
  185. +
  186. +    if (@_)
  187. +    {
  188. +        $self->id(shift);
  189. +    }
  190. +
  191. +    return $self->id();
  192.  }
  193.  
  194.  1;