diff options
| author | Derf Null <derf@finalrewind.org> | 2023-06-26 19:40:29 +0200 | 
|---|---|---|
| committer | Derf Null <derf@finalrewind.org> | 2023-06-26 19:50:49 +0200 | 
| commit | 0702a0edca47bef27e8beeac0aad5f7a5da4f14c (patch) | |
| tree | 9c3e85b59934c5039c962e0259f0ce8beab6e8e4 /lib/Travelynx/Command | |
| parent | 9b54276e8c3ddf4004207c1a92801b688541428c (diff) | |
Move hash_password to Model/Users
Diffstat (limited to 'lib/Travelynx/Command')
| -rw-r--r-- | lib/Travelynx/Command/account.pm | 26 | 
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/Travelynx/Command/account.pm b/lib/Travelynx/Command/account.pm index 6f8ea93..e6cfa5c 100644 --- a/lib/Travelynx/Command/account.pm +++ b/lib/Travelynx/Command/account.pm @@ -4,21 +4,12 @@ package Travelynx::Command::account;  #  # SPDX-License-Identifier: AGPL-3.0-or-later  use Mojo::Base 'Mojolicious::Command'; -use Crypt::Eksblowfish::Bcrypt qw(bcrypt en_base64); -use UUID::Tiny                 qw(:std); +use UUID::Tiny qw(:std);  has description => 'Add or remove user accounts';  has usage => sub { shift->extract_usage }; -sub hash_password { -	my ($password) = @_; -	my @salt_bytes = map { int( rand(255) ) + 1 } ( 1 .. 16 ); -	my $salt       = en_base64( pack( 'C[16]', @salt_bytes ) ); - -	return bcrypt( $password, '$2a$12$' . $salt ); -} -  sub add_user {  	my ( $self, $name, $email ) = @_; @@ -29,17 +20,16 @@ sub add_user {  		die;  	} -	my $token         = "tmp"; -	my $password      = substr( create_uuid_as_string(UUID_V4), 0, 18 ); -	my $password_hash = hash_password($password); +	my $token    = "tmp"; +	my $password = substr( create_uuid_as_string(UUID_V4), 0, 18 );  	my $tx      = $db->begin;  	my $user_id = $self->app->users->add( -		db            => $db, -		name          => $name, -		email         => $email, -		token         => $token, -		password_hash => $password_hash, +		db       => $db, +		name     => $name, +		email    => $email, +		token    => $token, +		password => $password,  	);  	my $success = $self->app->users->verify_registration_token(  		db             => $db,  | 
