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

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

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;