mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Minor fixes for phone validation
This commit is contained in:
parent
eb0ed877a0
commit
10c8fbf4c1
@ -47,10 +47,13 @@ class StoreUserRequest extends Request
|
||||
} else {
|
||||
$rules['email'] = ['email', new AttachableUser()];
|
||||
}
|
||||
|
||||
|
||||
if (Ninja::isHosted()) {
|
||||
$rules['id'] = new CanAddUserRule();
|
||||
$rules['phone'] = ['sometimes', new HasValidPhoneNumber()];
|
||||
|
||||
if($this->phone && isset($this->phone))
|
||||
$rules['phone'] = ['bail', 'string', 'sometimes', new HasValidPhoneNumber()];
|
||||
|
||||
}
|
||||
|
||||
return $rules;
|
||||
|
@ -43,7 +43,7 @@ class UpdateUserRequest extends Request
|
||||
$rules['email'] = ['email', 'sometimes', new UniqueUserRule($this->user, $input['email'])];
|
||||
}
|
||||
|
||||
if(Ninja::isHosted() && $this->phone_has_changed)
|
||||
if(Ninja::isHosted() && $this->phone_has_changed && $this->phone && isset($this->phone))
|
||||
$rules['phone'] = ['sometimes', 'bail', 'string', new HasValidPhoneNumber()];
|
||||
|
||||
return $rules;
|
||||
@ -65,7 +65,7 @@ class UpdateUserRequest extends Request
|
||||
$input['last_name'] = strip_tags($input['last_name']);
|
||||
}
|
||||
|
||||
if(array_key_exists('phone', $input) && strlen($input['phone']) > 1 && ($this->user->phone != $input['phone']))
|
||||
if(array_key_exists('phone', $input) && isset($input['phone']) && strlen($input['phone']) > 1 && ($this->user->phone != $input['phone']))
|
||||
$this->phone_has_changed = true;
|
||||
|
||||
if(array_key_exists('oauth_provider_id', $input) && $input['oauth_provider_id'] == '')
|
||||
|
@ -138,11 +138,14 @@ class UpdateReminder extends AbstractService
|
||||
}
|
||||
|
||||
if ($this->invoice->last_sent_date &&
|
||||
$this->settings->enable_reminder_endless) {
|
||||
$this->settings->enable_reminder_endless &&
|
||||
($this->invoice->reminder1_sent || $this->settings->schedule_reminder1 == "") &&
|
||||
($this->invoice->reminder2_sent || $this->settings->schedule_reminder2 == "") &&
|
||||
($this->invoice->reminder3_sent || $this->settings->schedule_reminder3 == "")) {
|
||||
$reminder_date = $this->addTimeInterval($this->invoice->last_sent_date, (int) $this->settings->endless_reminder_frequency_id);
|
||||
|
||||
if ($reminder_date) {
|
||||
$reminder_date->addSeconds($offset);
|
||||
// $reminder_date->addSeconds($offset);
|
||||
|
||||
if ($reminder_date->gt(Carbon::parse($this->invoice->next_send_date))) {
|
||||
$date_collection->push($reminder_date);
|
||||
|
@ -4777,7 +4777,7 @@ $LANG = array(
|
||||
'invoice_task_project' => 'Invoice Task Project',
|
||||
'invoice_task_project_help' => 'Add the project to the invoice line items',
|
||||
'bulk_action' => 'Bulk Action',
|
||||
'phone_validation_error' => 'This phone number is not valid, please enter in E.164 format',
|
||||
'phone_validation_error' => 'This mobile/cell phone number is not valid, please enter in E.164 format',
|
||||
'transaction' => 'Transaction',
|
||||
);
|
||||
|
||||
|
@ -56,9 +56,6 @@ class UserTest extends TestCase
|
||||
PasswordProtection::class
|
||||
);
|
||||
|
||||
// if (config('ninja.testvars.travis') !== false) {
|
||||
// $this->markTestSkipped('Skip test for Travis');
|
||||
// }
|
||||
}
|
||||
|
||||
public function testUserList()
|
||||
@ -72,6 +69,82 @@ class UserTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
public function testValidationRulesPhoneIsNull()
|
||||
{
|
||||
$this->withoutMiddleware(PasswordProtection::class);
|
||||
|
||||
$data = [
|
||||
'first_name' => 'hey',
|
||||
'last_name' => 'you',
|
||||
'email' => 'bob1@good.ole.boys.com',
|
||||
'company_user' => [
|
||||
'is_admin' => false,
|
||||
'is_owner' => false,
|
||||
'permissions' => 'create_client,create_invoice',
|
||||
],
|
||||
'phone' => null,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->post('/api/v1/users?include=company_user', $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
public function testValidationRulesPhoneIsBlankString()
|
||||
{
|
||||
$this->withoutMiddleware(PasswordProtection::class);
|
||||
|
||||
$data = [
|
||||
'first_name' => 'hey',
|
||||
'last_name' => 'you',
|
||||
'email' => 'bob1@good.ole.boys.com',
|
||||
'company_user' => [
|
||||
'is_admin' => false,
|
||||
'is_owner' => false,
|
||||
'permissions' => 'create_client,create_invoice',
|
||||
],
|
||||
'phone' => "",
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->post('/api/v1/users?include=company_user', $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
$user_id = $this->decodePrimaryKey($arr['data']['id']);
|
||||
$user = User::find($user_id);
|
||||
|
||||
|
||||
$data = [
|
||||
'first_name' => 'hey',
|
||||
'last_name' => 'you',
|
||||
'email' => 'bob1@good.ole.boys.com',
|
||||
'company_user' => [
|
||||
'is_admin' => false,
|
||||
'is_owner' => false,
|
||||
'permissions' => 'create_client,create_invoice',
|
||||
],
|
||||
'phone' => "",
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->putJson('/api/v1/users/'.$user->hashed_id.'?include=company_user', $data);
|
||||
|
||||
}
|
||||
|
||||
public function testUserStore()
|
||||
{
|
||||
$this->withoutMiddleware(PasswordProtection::class);
|
||||
|
Loading…
x
Reference in New Issue
Block a user