mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-30 19:42:57 -04:00 
			
		
		
		
	Fix for laravel 8 route file regression + psalm cleanup
This commit is contained in:
		
							parent
							
								
									39f084c030
								
							
						
					
					
						commit
						6479b2fd3e
					
				
							
								
								
									
										1
									
								
								.env.ci
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								.env.ci
									
									
									
									
									
								
							| @ -19,3 +19,4 @@ DB_HOST=127.0.0.1 | |||||||
| NINJA_ENVIRONMENT=hosted | NINJA_ENVIRONMENT=hosted | ||||||
| COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' | COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' | ||||||
| TRAVIS=true | TRAVIS=true | ||||||
|  | API_SECRET=superdoopersecrethere | ||||||
|  | |||||||
| @ -507,7 +507,7 @@ class CompanySettings extends BaseSettings | |||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Provides class defaults on init. |      * Provides class defaults on init. | ||||||
|      * @return object |      * @return stdClass | ||||||
|      */ |      */ | ||||||
|     public static function defaults(): stdClass |     public static function defaults(): stdClass | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -149,7 +149,7 @@ class FreeCompanySettings extends BaseSettings | |||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Provides class defaults on init. |      * Provides class defaults on init. | ||||||
|      * @return object |      * @return stdClass | ||||||
|      */ |      */ | ||||||
|     public static function defaults(): stdClass |     public static function defaults(): stdClass | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -34,12 +34,14 @@ class SetEmailDb | |||||||
|         ]; |         ]; | ||||||
| 
 | 
 | ||||||
|         if ($request->input('email') && config('ninja.db.multi_db_enabled')) { |         if ($request->input('email') && config('ninja.db.multi_db_enabled')) { | ||||||
|  |             info("trying to find db"); | ||||||
|             if (! MultiDB::userFindAndSetDb($request->input('email'))) { |             if (! MultiDB::userFindAndSetDb($request->input('email'))) { | ||||||
|                 return response()->json($error, 403); |                 return response()->json($error, 400); | ||||||
|             } |             } | ||||||
|         } else { |  | ||||||
|             return response()->json($error, 403); |  | ||||||
|         }  |         }  | ||||||
|  |         // else {
 | ||||||
|  |         //     return response()->json($error, 403);
 | ||||||
|  |         // }
 | ||||||
| 
 | 
 | ||||||
|         return $next($request); |         return $next($request); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -112,7 +112,7 @@ class UpdateClientRequest extends Request | |||||||
|      * are saveable |      * are saveable | ||||||
|      * |      * | ||||||
|      * @param  object $settings |      * @param  object $settings | ||||||
|      * @return object $settings |      * @return stdClass $settings | ||||||
|      */ |      */ | ||||||
|     private function filterSaveableSettings($settings) |     private function filterSaveableSettings($settings) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -76,7 +76,7 @@ class UpdateCompanyRequest extends Request | |||||||
|      * are saveable |      * are saveable | ||||||
|      * |      * | ||||||
|      * @param  object $settings |      * @param  object $settings | ||||||
|      * @return object $settings |      * @return stdClass $settings | ||||||
|      */ |      */ | ||||||
|     private function filterSaveableSettings($settings) |     private function filterSaveableSettings($settings) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -58,7 +58,7 @@ class UpdateGroupSettingRequest extends Request | |||||||
|      * are saveable |      * are saveable | ||||||
|      * |      * | ||||||
|      * @param  object $settings |      * @param  object $settings | ||||||
|      * @return object $settings |      * @return stdClass $settings | ||||||
|      */ |      */ | ||||||
|     private function filterSaveableSettings($settings) |     private function filterSaveableSettings($settings) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -285,7 +285,7 @@ class Client extends BaseModel implements HasLocalePreference | |||||||
|      * of settings which have been merged from |      * of settings which have been merged from | ||||||
|      * Client > Group > Company levels. |      * Client > Group > Company levels. | ||||||
|      * |      * | ||||||
|      * @return object stdClass object of settings |      * @return stdClass stdClass object of settings | ||||||
|      */ |      */ | ||||||
|     public function getMergedSettings() :object |     public function getMergedSettings() :object | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -324,32 +324,32 @@ class CompanyGateway extends BaseModel | |||||||
|      * @param $invoice_count |      * @param $invoice_count | ||||||
|      * @return stdClass |      * @return stdClass | ||||||
|      */ |      */ | ||||||
|     public function calcGatewayFeeObject($amount, $invoice_count) |     // public function calcGatewayFeeObject($amount, $invoice_count)
 | ||||||
|     { |     // {
 | ||||||
|         $total_gateway_fee = $this->calcGatewayFee($amount); |     //     $total_gateway_fee = $this->calcGatewayFee($amount);
 | ||||||
| 
 | 
 | ||||||
|         $fee_object = new stdClass; |     //     $fee_object = new stdClass;
 | ||||||
| 
 | 
 | ||||||
|         $fees_and_limits = $this->getFeesAndLimits(); |     //     $fees_and_limits = $this->getFeesAndLimits();
 | ||||||
| 
 | 
 | ||||||
|         if (! $fees_and_limits) { |     //     if (! $fees_and_limits) {
 | ||||||
|             return $fee_object; |     //         return $fee_object;
 | ||||||
|         } |     //     }
 | ||||||
| 
 | 
 | ||||||
|         $fee_component_amount = $fees_and_limits->fee_amount ?: 0; |     //     $fee_component_amount = $fees_and_limits->fee_amount ?: 0;
 | ||||||
|         $fee_component_percent = $fees_and_limits->fee_percent ? ($amount * $fees_and_limits->fee_percent / 100) : 0; |     //     $fee_component_percent = $fees_and_limits->fee_percent ? ($amount * $fees_and_limits->fee_percent / 100) : 0;
 | ||||||
| 
 | 
 | ||||||
|         $combined_fee_component = $fee_component_amount + $fee_component_percent; |     //     $combined_fee_component = $fee_component_amount + $fee_component_percent;
 | ||||||
| 
 | 
 | ||||||
|         $fee_component_tax_name1 = $fees_and_limits->fee_tax_name1 ?: ''; |     //     $fee_component_tax_name1 = $fees_and_limits->fee_tax_name1 ?: '';
 | ||||||
|         $fee_component_tax_rate1 = $fees_and_limits->fee_tax_rate1 ? ($combined_fee_component * $fees_and_limits->fee_tax_rate1 / 100) : 0; |     //     $fee_component_tax_rate1 = $fees_and_limits->fee_tax_rate1 ? ($combined_fee_component * $fees_and_limits->fee_tax_rate1 / 100) : 0;
 | ||||||
| 
 | 
 | ||||||
|         $fee_component_tax_name2 = $fees_and_limits->fee_tax_name2 ?: ''; |     //     $fee_component_tax_name2 = $fees_and_limits->fee_tax_name2 ?: '';
 | ||||||
|         $fee_component_tax_rate2 = $fees_and_limits->fee_tax_rate2 ? ($combined_fee_component * $fees_and_limits->fee_tax_rate2 / 100) : 0; |     //     $fee_component_tax_rate2 = $fees_and_limits->fee_tax_rate2 ? ($combined_fee_component * $fees_and_limits->fee_tax_rate2 / 100) : 0;
 | ||||||
| 
 | 
 | ||||||
|         $fee_component_tax_name3 = $fees_and_limits->fee_tax_name3 ?: ''; |     //     $fee_component_tax_name3 = $fees_and_limits->fee_tax_name3 ?: '';
 | ||||||
|         $fee_component_tax_rate3 = $fees_and_limits->fee_tax_rate3 ? ($combined_fee_component * $fees_and_limits->fee_tax_rate3 / 100) : 0; |     //     $fee_component_tax_rate3 = $fees_and_limits->fee_tax_rate3 ? ($combined_fee_component * $fees_and_limits->fee_tax_rate3 / 100) : 0;
 | ||||||
|     } |     // }
 | ||||||
| 
 | 
 | ||||||
|     public function resolveRouteBinding($value, $field = NULL) |     public function resolveRouteBinding($value, $field = NULL) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -185,7 +185,7 @@ class Credit extends BaseModel | |||||||
|     /** |     /** | ||||||
|      * Access the invoice calculator object. |      * Access the invoice calculator object. | ||||||
|      * |      * | ||||||
|      * @return object The invoice calculator object getters |      * @return stdClass The invoice calculator object getters | ||||||
|      */ |      */ | ||||||
|     public function calc() |     public function calc() | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -356,7 +356,7 @@ class Invoice extends BaseModel | |||||||
|     /** |     /** | ||||||
|      * Access the invoice calculator object. |      * Access the invoice calculator object. | ||||||
|      * |      * | ||||||
|      * @return object The invoice calculator object getters |      * @return stdClass The invoice calculator object getters | ||||||
|      */ |      */ | ||||||
|     public function calc() |     public function calc() | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -159,7 +159,7 @@ class Quote extends BaseModel | |||||||
|     /** |     /** | ||||||
|      * Access the quote calculator object. |      * Access the quote calculator object. | ||||||
|      * |      * | ||||||
|      * @return object The quote calculator object getters |      * @return stdClass The quote calculator object getters | ||||||
|      */ |      */ | ||||||
|     public function calc() |     public function calc() | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -72,7 +72,7 @@ class BasePaymentDriver | |||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Returns the Omnipay driver. |      * Returns the Omnipay driver. | ||||||
|      * @return object Omnipay initialized object |      * @return stdClass Omnipay initialized object | ||||||
|      */ |      */ | ||||||
|     protected function gateway() |     protected function gateway() | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -41,6 +41,10 @@ class PaymentRepository extends BaseRepository | |||||||
|         $this->credit_repo = $credit_repo; |         $this->credit_repo = $credit_repo; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /**  | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  | 
 | ||||||
|     public function getClassName() |     public function getClassName() | ||||||
|     { |     { | ||||||
|         return Payment::class; |         return Payment::class; | ||||||
|  | |||||||
| @ -31,7 +31,7 @@ class RecurringInvoiceRepository extends BaseRepository | |||||||
| 
 | 
 | ||||||
|         $invoice->save(); |         $invoice->save(); | ||||||
| 
 | 
 | ||||||
|         $invoice_calc = new InvoiceSum($invoice, $invoice->settings); |         $invoice_calc = new InvoiceSum($invoice); | ||||||
| 
 | 
 | ||||||
|         $invoice->service() |         $invoice->service() | ||||||
|                 ->applyNumber() |                 ->applyNumber() | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ class TaskRepository extends BaseRepository | |||||||
|     /** |     /** | ||||||
|      * Gets the class name. |      * Gets the class name. | ||||||
|      * |      * | ||||||
|      * @return     string The class name. |      * @return string The class name. | ||||||
|      */ |      */ | ||||||
|     public function getClassName()  |     public function getClassName()  | ||||||
|     { |     { | ||||||
| @ -40,8 +40,8 @@ class TaskRepository extends BaseRepository | |||||||
|     /** |     /** | ||||||
|      * Saves the task and its contacts. |      * Saves the task and its contacts. | ||||||
|      * |      * | ||||||
|      * @param      array                           $data    The data |      * @param      array                         $data    The data | ||||||
|      * @param      \App\Models\task              $task  The task |      * @param      \App\Models\Task              $task  The task | ||||||
|      * |      * | ||||||
|      * @return     task|null  task Object |      * @return     task|null  task Object | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -33,7 +33,7 @@ class SendEmail | |||||||
|      */ |      */ | ||||||
|     public function run() |     public function run() | ||||||
|     { |     { | ||||||
|         $email_builder = (new PaymentEmail())->build($this->payment, $contact); |         $email_builder = (new PaymentEmail())->build($this->payment, $this->contact); | ||||||
| 
 | 
 | ||||||
|         $this->payment->client->contacts->each(function ($contact) use ($email_builder) { |         $this->payment->client->contacts->each(function ($contact) use ($email_builder) { | ||||||
|             if ($contact->send && $contact->email) { |             if ($contact->send && $contact->email) { | ||||||
|  | |||||||
| @ -54,7 +54,6 @@ class UserTransformer extends EntityTransformer | |||||||
|             'created_at' => (int) $user->created_at, |             'created_at' => (int) $user->created_at, | ||||||
|             'updated_at' => (int) $user->updated_at, |             'updated_at' => (int) $user->updated_at, | ||||||
|             'archived_at' => (int) $user->deleted_at, |             'archived_at' => (int) $user->deleted_at, | ||||||
|             'created_at' => (int) $user->created_at, |  | ||||||
|             'is_deleted' => (bool) $user->is_deleted, |             'is_deleted' => (bool) $user->is_deleted, | ||||||
|             'phone' => $user->phone ?: '', |             'phone' => $user->phone ?: '', | ||||||
|             'email_verified_at' => $user->getEmailVerifiedAt(), |             'email_verified_at' => $user->getEmailVerifiedAt(), | ||||||
|  | |||||||
| @ -57,7 +57,7 @@ class EmailStats | |||||||
|      * Iterates through a list of companies |      * Iterates through a list of companies | ||||||
|      * and flushes the email sent data. |      * and flushes the email sent data. | ||||||
|      * |      * | ||||||
|      * @param  string $companies The company key |      * @param  Collection $companies The company key | ||||||
|      * @return void |      * @return void | ||||||
|      */ |      */ | ||||||
|     public static function clearCompanies($companies) |     public static function clearCompanies($companies) | ||||||
|  | |||||||
| @ -251,8 +251,8 @@ class HtmlEngine | |||||||
|         $data['$contact.phone'] = ['value' => $this->contact->phone, 'label' => ctrans('texts.phone')]; |         $data['$contact.phone'] = ['value' => $this->contact->phone, 'label' => ctrans('texts.phone')]; | ||||||
| 
 | 
 | ||||||
|         $data['$contact.name'] = ['value' => isset($this->contact) ? $this->contact->present()->name() : 'no contact name on record', 'label' => ctrans('texts.contact_name')]; |         $data['$contact.name'] = ['value' => isset($this->contact) ? $this->contact->present()->name() : 'no contact name on record', 'label' => ctrans('texts.contact_name')]; | ||||||
|         $data['$contact.first_name'] = ['value' => isset($contact) ? $contact->first_name : '', 'label' => ctrans('texts.first_name')]; |         $data['$contact.first_name'] = ['value' => isset($this->contact) ? $this->contact->first_name : '', 'label' => ctrans('texts.first_name')]; | ||||||
|         $data['$contact.last_name'] = ['value' => isset($contact) ? $contact->last_name : '', 'label' => ctrans('texts.last_name')]; |         $data['$contact.last_name'] = ['value' => isset($this->contact) ? $this->contact->last_name : '', 'label' => ctrans('texts.last_name')]; | ||||||
|         $data['$contact.custom1'] = ['value' => isset($this->contact) ? $this->contact->custom_value1 : ' ', 'label' => $this->makeCustomField('contact1')]; |         $data['$contact.custom1'] = ['value' => isset($this->contact) ? $this->contact->custom_value1 : ' ', 'label' => $this->makeCustomField('contact1')]; | ||||||
|         $data['$contact.custom2'] = ['value' => isset($this->contact) ? $this->contact->custom_value2 : ' ', 'label' => $this->makeCustomField('contact1')]; |         $data['$contact.custom2'] = ['value' => isset($this->contact) ? $this->contact->custom_value2 : ' ', 'label' => $this->makeCustomField('contact1')]; | ||||||
|         $data['$contact.custom3'] = ['value' => isset($this->contact) ? $this->contact->custom_value3 : ' ', 'label' => $this->makeCustomField('contact1')]; |         $data['$contact.custom3'] = ['value' => isset($this->contact) ? $this->contact->custom_value3 : ' ', 'label' => $this->makeCustomField('contact1')]; | ||||||
|  | |||||||
| @ -35,7 +35,6 @@ class Phantom | |||||||
|      * Phantom JS API. |      * Phantom JS API. | ||||||
|      * |      * | ||||||
|      * @param $invitation |      * @param $invitation | ||||||
|      * @return pdf HTML to PDF conversion |  | ||||||
|      */ |      */ | ||||||
|     public function generate($invitation)  |     public function generate($invitation)  | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -139,7 +139,7 @@ trait ClientGroupSettingsSaver | |||||||
|      * so that it can be saved cleanly |      * so that it can be saved cleanly | ||||||
|      * |      * | ||||||
|      * @param  array $settings The settings request() array |      * @param  array $settings The settings request() array | ||||||
|      * @return object          stdClass object |      * @return stdClass          stdClass object | ||||||
|      */ |      */ | ||||||
|     private function checkSettingType($settings) : stdClass |     private function checkSettingType($settings) : stdClass | ||||||
|     { |     { | ||||||
| @ -214,8 +214,7 @@ trait ClientGroupSettingsSaver | |||||||
|             case 'array': |             case 'array': | ||||||
|                 return is_array($value); |                 return is_array($value); | ||||||
|             case 'json': |             case 'json': | ||||||
|                 json_decode($string); |                 json_decode($value); | ||||||
| 
 |  | ||||||
|                     return json_last_error() == JSON_ERROR_NONE; |                     return json_last_error() == JSON_ERROR_NONE; | ||||||
|             default: |             default: | ||||||
|                 return false; |                 return false; | ||||||
|  | |||||||
| @ -71,7 +71,7 @@ trait CompanyGatewayFeesAndLimitsSaver | |||||||
|             case 'array': |             case 'array': | ||||||
|                 return is_array($value); |                 return is_array($value); | ||||||
|             case 'json': |             case 'json': | ||||||
|                 json_decode($string); |                 json_decode($value); | ||||||
| 
 | 
 | ||||||
|                     return json_last_error() == JSON_ERROR_NONE; |                     return json_last_error() == JSON_ERROR_NONE; | ||||||
|             default: |             default: | ||||||
|  | |||||||
| @ -131,7 +131,7 @@ trait CompanySettingsSaver | |||||||
|      * so that it can be saved cleanly |      * so that it can be saved cleanly | ||||||
|      * |      * | ||||||
|      * @param  array $settings The settings request() array |      * @param  array $settings The settings request() array | ||||||
|      * @return object          stdClass object |      * @return stdClass       stdClass object | ||||||
|      */ |      */ | ||||||
|     private function checkSettingType($settings) : stdClass |     private function checkSettingType($settings) : stdClass | ||||||
|     { |     { | ||||||
| @ -224,7 +224,7 @@ trait CompanySettingsSaver | |||||||
|             case 'array': |             case 'array': | ||||||
|                 return is_array($value); |                 return is_array($value); | ||||||
|             case 'json': |             case 'json': | ||||||
|                 json_decode($string); |                 json_decode($value); | ||||||
| 
 | 
 | ||||||
|                     return json_last_error() == JSON_ERROR_NONE; |                     return json_last_error() == JSON_ERROR_NONE; | ||||||
|             default: |             default: | ||||||
|  | |||||||
| @ -442,7 +442,7 @@ trait GeneratesCounter | |||||||
|      * check if we need to reset here. |      * check if we need to reset here. | ||||||
|      * |      * | ||||||
|      * @param Client $client client entity |      * @param Client $client client entity | ||||||
|      * @return false |      * @return void | ||||||
|      */ |      */ | ||||||
|     private function resetCounters(Client $client) |     private function resetCounters(Client $client) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -44,13 +44,9 @@ trait Inviteable | |||||||
| 
 | 
 | ||||||
|     public function getLink() :string |     public function getLink() :string | ||||||
|     { |     { | ||||||
|         //$entity_type = strtolower(class_basename($this->entityType()));
 |  | ||||||
| 
 | 
 | ||||||
|         $entity_type = Str::snake(class_basename($this->entityType())); |         $entity_type = Str::snake(class_basename($this->entityType())); | ||||||
| 
 | 
 | ||||||
|         //$this->with('company','contact',$this->entity_type);
 |  | ||||||
|         //$this->with('company');
 |  | ||||||
| 
 |  | ||||||
|         $domain = isset($this->company->portal_domain) ?: $this->company->domain(); |         $domain = isset($this->company->portal_domain) ?: $this->company->domain(); | ||||||
| 
 | 
 | ||||||
|         switch ($this->company->portal_mode) { |         switch ($this->company->portal_mode) { | ||||||
| @ -65,6 +61,9 @@ trait Inviteable | |||||||
|                 return $domain.'client/'.$entity_type.'/'.$this->key; |                 return $domain.'client/'.$entity_type.'/'.$this->key; | ||||||
|                 break; |                 break; | ||||||
| 
 | 
 | ||||||
|  |             default: | ||||||
|  |                 return ''; | ||||||
|  |                 break; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -52,15 +52,17 @@ trait MakesDates | |||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Formats a date. |      * Formats a date. | ||||||
|      * @param  Carbon/String $date   Carbon object or date string |      * @param  Carbon|string $date   Carbon object or date string | ||||||
|      * @param  string $format The date display format |      * @param  string $format The date display format | ||||||
|      * @return string         The formatted date |      * @return string         The formatted date | ||||||
|      */ |      */ | ||||||
|     public function formatDate($date, string $format) :string |     public function formatDate($date, string $format) :string | ||||||
|     { |     { | ||||||
|         if (! $date || strlen($date) < 1) { |         if(!isset($date)) | ||||||
|             return ''; |             return ''; | ||||||
|         } |         // if (!$date || strlen($date) < 1) {
 | ||||||
|  |         //     return '';
 | ||||||
|  |         // }
 | ||||||
| 
 | 
 | ||||||
|         if (is_string($date)) { |         if (is_string($date)) { | ||||||
|             $date = $this->convertToDateObject($date); |             $date = $this->convertToDateObject($date); | ||||||
|  | |||||||
| @ -67,7 +67,7 @@ trait MakesHash | |||||||
|             $decoded_array = $hashids->decode($value); |             $decoded_array = $hashids->decode($value); | ||||||
| 
 | 
 | ||||||
|             if (! is_array($decoded_array)) { |             if (! is_array($decoded_array)) { | ||||||
|                 throw new Exception("Invalid Primary Key"); |                 throw new \Exception("Invalid Primary Key"); | ||||||
|                 //response()->json(['error'=>'Invalid primary key'], 400);
 |                 //response()->json(['error'=>'Invalid primary key'], 400);
 | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										622
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										622
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										11
									
								
								psalm.xml
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								psalm.xml
									
									
									
									
									
								
							| @ -51,6 +51,17 @@ | |||||||
|       <directory name="app" />  |       <directory name="app" />  | ||||||
|     </errorLevel> |     </errorLevel> | ||||||
|   </InvalidScalarArgument>  |   </InvalidScalarArgument>  | ||||||
|  |   <UndefinedMagicPropertyFetch> | ||||||
|  |     <errorLevel type="suppress"> | ||||||
|  |       <directory name="app" />  | ||||||
|  |     </errorLevel> | ||||||
|  |   </UndefinedMagicPropertyFetch>  | ||||||
|  |   <InvalidNullableReturnType> | ||||||
|  |     <errorLevel type="suppress"> | ||||||
|  |       <directory name="app" />  | ||||||
|  |     </errorLevel> | ||||||
|  |   </InvalidNullableReturnType>  | ||||||
|  |   | ||||||
| 
 | 
 | ||||||
| </issueHandlers> | </issueHandlers> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -16,10 +16,9 @@ Route::group(['middleware' => ['api_secret_check']], function () { | |||||||
|     Route::post('api/v1/oauth_login', 'Auth\LoginController@oauthApiLogin'); |     Route::post('api/v1/oauth_login', 'Auth\LoginController@oauthApiLogin'); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| Route::group(['api_secret_check', 'email_db'], function () { | Route::group(['middleware' => ['api_secret_check', 'email_db']], function () { | ||||||
|     Route::post('api/v1/login', 'Auth\LoginController@apiLogin')->name('login.submit'); |     Route::post('api/v1/login', 'Auth\LoginController@apiLogin')->name('login.submit'); | ||||||
|     Route::post('api/v1/reset_password', 'Auth\ForgotPasswordController@sendResetLinkEmail'); |     Route::post('api/v1/reset_password', 'Auth\ForgotPasswordController@sendResetLinkEmail'); | ||||||
| 
 |  | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'api/v1', 'as' => 'api.'], function () { | Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'api/v1', 'as' => 'api.'], function () { | ||||||
|  | |||||||
| @ -24,6 +24,7 @@ use Illuminate\Http\Request; | |||||||
| use Illuminate\Support\Facades\Log; | use Illuminate\Support\Facades\Log; | ||||||
| use Illuminate\Support\Facades\Session; | use Illuminate\Support\Facades\Session; | ||||||
| use Tests\TestCase; | use Tests\TestCase; | ||||||
|  | use Illuminate\Validation\ValidationException; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * @test |  * @test | ||||||
| @ -141,6 +142,10 @@ class LoginTest extends TestCase | |||||||
| 
 | 
 | ||||||
|     public function testApiLogin() |     public function testApiLogin() | ||||||
|     { |     { | ||||||
|  |         Account::all()->each(function ($account){ | ||||||
|  |             $account->delete(); | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|         $account = Account::factory()->create(); |         $account = Account::factory()->create(); | ||||||
|         $user = User::factory()->create([ |         $user = User::factory()->create([ | ||||||
|             'account_id' => $account->id, |             'account_id' => $account->id, | ||||||
| @ -177,15 +182,28 @@ class LoginTest extends TestCase | |||||||
|         $this->assertTrue($user->company_users->first() !== null); |         $this->assertTrue($user->company_users->first() !== null); | ||||||
|         $this->assertTrue($user->company_user->account !== null); |         $this->assertTrue($user->company_user->account !== null); | ||||||
| 
 | 
 | ||||||
|  |         $this->assertEquals($user->email, 'test@example.com'); | ||||||
|  |         $this->assertTrue(\Hash::check('123456', $user->password)); | ||||||
|  | 
 | ||||||
|         $data = [ |         $data = [ | ||||||
|             'email' => 'test@example.com', |             'email' => 'test@example.com', | ||||||
|             'password' => '123456', |             'password' => '123456', | ||||||
|         ]; |         ]; | ||||||
| 
 | 
 | ||||||
|  |         try{ | ||||||
|         $response = $this->withHeaders([ |         $response = $this->withHeaders([ | ||||||
|                 'X-API-SECRET' => config('ninja.api_secret'), |             'X-API-SECRET' => config('ninja.api_secret'), | ||||||
|             ])->post('/api/v1/login', $data); |             ])->post('/api/v1/login', $data); | ||||||
| 
 | 
 | ||||||
|  |         } catch (ValidationException $e) { | ||||||
|  |             $message = json_decode($e->validator->getMessageBag(), 1); | ||||||
|  |             info(print_r($message,1)); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $arr = $response->json(); | ||||||
|  | 
 | ||||||
|  |         info(print_r($arr,1)); | ||||||
|  |          | ||||||
|         $response->assertStatus(200); |         $response->assertStatus(200); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user