| 1 | package Reaction::InterfaceModel::Object::User::Role::ConfirmationCodeSupport; | ||
| 2 | |||
| 3 | use Reaction::Role; | ||
| 4 | use Crypt::Eksblowfish::Bcrypt (); | ||
| 5 | use namespace::clean -except => [ qw(meta) ]; | ||
| 6 | |||
| 7 | requires 'identity_string'; | ||
| 8 | |||
| 9 | sub generate_confirmation_code { | ||
| 10 | my $self = shift; | ||
| 11 | my $salt = join(q{}, map { chr(int(rand(256))) } 1 .. 16); | ||
| 12 | $salt = Crypt::Eksblowfish::Bcrypt::en_base64( $salt ); | ||
| 13 | my $settings_base = join(q{},'$2','a','$',sprintf("%02i", 8), '$'); | ||
| 14 | return Crypt::Eksblowfish::Bcrypt::bcrypt( | ||
| 15 | $self->identity_string, $settings_base . $salt | ||
| 16 | ); | ||
| 17 | } | ||
| 18 | |||
| 19 | 1; |