aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/InterfaceModel/Object/User/Role/ConfirmationCodeSupport.pm
blob: 4830d08bc1debdc77992a2b8214d72f584d2f984 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package Reaction::InterfaceModel::Object::User::Role::ConfirmationCodeSupport;

use Reaction::Role;
use Crypt::Eksblowfish::Bcrypt ();
use namespace::clean -except => [ qw(meta) ];

requires 'identity_string';

sub generate_confirmation_code {
    my $self = shift;
    my $salt = join(q{}, map { chr(int(rand(256))) } 1 .. 16);
    $salt = Crypt::Eksblowfish::Bcrypt::en_base64( $salt );
    my $settings_base = join(q{},'$2','a','$',sprintf("%02i", 8), '$');
    return Crypt::Eksblowfish::Bcrypt::bcrypt(
        $self->identity_string, $settings_base . $salt
    );
}

1;