From 7b233def5f5da906b99b56755be9c26bff17ae6e Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 2 Apr 2017 20:46:01 +0300 Subject: [PATCH] strtolower new keys --- app/Http/Controllers/AppController.php | 4 ++-- app/Http/Controllers/TokenController.php | 2 +- app/Http/Controllers/UserController.php | 4 ++-- app/Models/Client.php | 2 +- app/Models/Contact.php | 2 +- app/Models/User.php | 2 +- app/Ninja/Repositories/AccountRepository.php | 16 ++++++++-------- app/Ninja/Repositories/ContactRepository.php | 2 +- app/Ninja/Repositories/InvoiceRepository.php | 6 +++--- database/seeds/UserTableSeeder.php | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index 839d82c36670..13e96ae7443b 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -56,7 +56,7 @@ class AppController extends BaseController $test = Input::get('test'); $app = Input::get('app'); - $app['key'] = env('APP_KEY') ?: str_random(RANDOM_KEY_LENGTH); + $app['key'] = env('APP_KEY') ?: strtolower(str_random(RANDOM_KEY_LENGTH)); $app['debug'] = Input::get('debug') ? 'true' : 'false'; $app['https'] = Input::get('https') ? 'true' : 'false'; @@ -101,7 +101,7 @@ class AppController extends BaseController $_ENV['MAIL_FROM_ADDRESS'] = $mail['from']['address']; $_ENV['MAIL_PASSWORD'] = $mail['password']; $_ENV['PHANTOMJS_CLOUD_KEY'] = 'a-demo-key-with-low-quota-per-ip-address'; - $_ENV['PHANTOMJS_SECRET'] = str_random(RANDOM_KEY_LENGTH); + $_ENV['PHANTOMJS_SECRET'] = strtolower(str_random(RANDOM_KEY_LENGTH)); $_ENV['MAILGUN_DOMAIN'] = $mail['mailgun_domain']; $_ENV['MAILGUN_SECRET'] = $mail['mailgun_secret']; diff --git a/app/Http/Controllers/TokenController.php b/app/Http/Controllers/TokenController.php index 414151fd3ee2..db0c0d715f52 100644 --- a/app/Http/Controllers/TokenController.php +++ b/app/Http/Controllers/TokenController.php @@ -145,7 +145,7 @@ class TokenController extends BaseController } else { $token = AccountToken::createNew(); $token->name = trim(Input::get('name')); - $token->token = str_random(RANDOM_KEY_LENGTH); + $token->token = strtolower(str_random(RANDOM_KEY_LENGTH)); } $token->save(); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 7ea94be5721d..c6429521a875 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -199,8 +199,8 @@ class UserController extends BaseController $user->username = trim(Input::get('email')); $user->email = trim(Input::get('email')); $user->registered = true; - $user->password = str_random(RANDOM_KEY_LENGTH); - $user->confirmation_code = str_random(RANDOM_KEY_LENGTH); + $user->password = strtolower(str_random(RANDOM_KEY_LENGTH)); + $user->confirmation_code = strtolower(str_random(RANDOM_KEY_LENGTH)); $user->public_id = $lastUser->public_id + 1; if (Auth::user()->hasFeature(FEATURE_USER_PERMISSIONS)) { $user->is_admin = boolval(Input::get('is_admin')); diff --git a/app/Models/Client.php b/app/Models/Client.php index 07c21b5768c0..5a42983d38ba 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -290,7 +290,7 @@ class Client extends EntityModel if (isset($data['contact_key']) && $this->account->account_key == env('NINJA_LICENSE_ACCOUNT_KEY')) { $contact->contact_key = $data['contact_key']; } else { - $contact->contact_key = str_random(RANDOM_KEY_LENGTH); + $contact->contact_key = strtolower(str_random(RANDOM_KEY_LENGTH)); } } diff --git a/app/Models/Contact.php b/app/Models/Contact.php index c19ba4bda6cb..087b1a356ac9 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -119,7 +119,7 @@ class Contact extends EntityModel implements AuthenticatableContract, CanResetPa public function getContactKeyAttribute($contact_key) { if (empty($contact_key) && $this->id) { - $this->contact_key = $contact_key = str_random(RANDOM_KEY_LENGTH); + $this->contact_key = $contact_key = strtolower(str_random(RANDOM_KEY_LENGTH)); static::where('id', $this->id)->update(['contact_key' => $contact_key]); } diff --git a/app/Models/User.php b/app/Models/User.php index 1688fd4085de..240234d878f5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -263,7 +263,7 @@ class User extends Authenticatable // if the user changes their email then they need to reconfirm it if ($user->isEmailBeingChanged()) { $user->confirmed = 0; - $user->confirmation_code = str_random(RANDOM_KEY_LENGTH); + $user->confirmation_code = strtolower(str_random(RANDOM_KEY_LENGTH)); } } diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index f67dbb6b8251..9ff3d67beed4 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -42,7 +42,7 @@ class AccountRepository $account = new Account(); $account->ip = Request::getClientIp(); - $account->account_key = str_random(RANDOM_KEY_LENGTH); + $account->account_key = strtolower(str_random(RANDOM_KEY_LENGTH)); $account->company_id = $company->id; // Track referal code @@ -62,14 +62,14 @@ class AccountRepository $user = new User(); if (! $firstName && ! $lastName && ! $email && ! $password) { - $user->password = str_random(RANDOM_KEY_LENGTH); - $user->username = str_random(RANDOM_KEY_LENGTH); + $user->password = strtolower(str_random(RANDOM_KEY_LENGTH)); + $user->username = strtolower(str_random(RANDOM_KEY_LENGTH)); } else { $user->first_name = $firstName; $user->last_name = $lastName; $user->email = $user->username = $email; if (! $password) { - $password = str_random(RANDOM_KEY_LENGTH); + $password = strtolower(str_random(RANDOM_KEY_LENGTH)); } $user->password = bcrypt($password); } @@ -78,7 +78,7 @@ class AccountRepository $user->registered = ! Utils::isNinja() || $email; if (! $user->confirmed) { - $user->confirmation_code = str_random(RANDOM_KEY_LENGTH); + $user->confirmation_code = strtolower(str_random(RANDOM_KEY_LENGTH)); } $account->users()->save($user); @@ -332,7 +332,7 @@ class AccountRepository $invitation->public_id = $publicId; $invitation->invoice_id = $invoice->id; $invitation->contact_id = $client->contacts()->first()->id; - $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH); + $invitation->invitation_key = strtolower(str_random(RANDOM_KEY_LENGTH)); $invitation->save(); return $invitation; @@ -356,7 +356,7 @@ class AccountRepository $account->company_id = $company->id; $account->save(); - $random = str_random(RANDOM_KEY_LENGTH); + $random = strtolower(str_random(RANDOM_KEY_LENGTH)); $user = new User(); $user->registered = true; $user->confirmed = true; @@ -683,7 +683,7 @@ class AccountRepository $token = AccountToken::createNew($user); $token->name = $name; - $token->token = str_random(RANDOM_KEY_LENGTH); + $token->token = strtolower(str_random(RANDOM_KEY_LENGTH)); $token->save(); } } diff --git a/app/Ninja/Repositories/ContactRepository.php b/app/Ninja/Repositories/ContactRepository.php index 878e1263a06c..7a72fda3e2d3 100644 --- a/app/Ninja/Repositories/ContactRepository.php +++ b/app/Ninja/Repositories/ContactRepository.php @@ -17,7 +17,7 @@ class ContactRepository extends BaseRepository $contact->send_invoice = true; $contact->client_id = $data['client_id']; $contact->is_primary = Contact::scope()->where('client_id', '=', $contact->client_id)->count() == 0; - $contact->contact_key = str_random(RANDOM_KEY_LENGTH); + $contact->contact_key = strtolower(str_random(RANDOM_KEY_LENGTH)); } else { $contact = Contact::scope($publicId)->firstOrFail(); } diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 8cc7ccc79668..b52982841163 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -716,7 +716,7 @@ class InvoiceRepository extends BaseRepository $invitation = Invitation::createNew($invoice); $invitation->invoice_id = $invoice->id; $invitation->contact_id = $contact->id; - $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH); + $invitation->invitation_key = strtolower(str_random(RANDOM_KEY_LENGTH)); $invitation->save(); } elseif (! in_array($contact->id, $sendInvoiceIds) && $invitation) { $invitation->delete(); @@ -842,7 +842,7 @@ class InvoiceRepository extends BaseRepository foreach ($invoice->invitations as $invitation) { $cloneInvitation = Invitation::createNew($invoice); $cloneInvitation->contact_id = $invitation->contact_id; - $cloneInvitation->invitation_key = str_random(RANDOM_KEY_LENGTH); + $cloneInvitation->invitation_key = strtolower(str_random(RANDOM_KEY_LENGTH)); $clone->invitations()->save($cloneInvitation); } @@ -1018,7 +1018,7 @@ class InvoiceRepository extends BaseRepository foreach ($recurInvoice->invitations as $recurInvitation) { $invitation = Invitation::createNew($recurInvitation); $invitation->contact_id = $recurInvitation->contact_id; - $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH); + $invitation->invitation_key = strtolower(str_random(RANDOM_KEY_LENGTH)); $invoice->invitations()->save($invitation); } diff --git a/database/seeds/UserTableSeeder.php b/database/seeds/UserTableSeeder.php index 54cea6d967f9..d03f0ecccace 100644 --- a/database/seeds/UserTableSeeder.php +++ b/database/seeds/UserTableSeeder.php @@ -32,7 +32,7 @@ class UserTableSeeder extends Seeder 'state' => $faker->state, 'postal_code' => $faker->postcode, 'country_id' => Country::all()->random()->id, - 'account_key' => str_random(RANDOM_KEY_LENGTH), + 'account_key' => strtolower(str_random(RANDOM_KEY_LENGTH)), 'invoice_terms' => $faker->text($faker->numberBetween(50, 300)), 'work_phone' => $faker->phoneNumber, 'work_email' => $faker->safeEmail,