chore: add thecodingmachine/safe package (#2630)
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use function Safe\fopen;
|
||||
use App\Models\User\User;
|
||||
use function Safe\fclose;
|
||||
use App\Helpers\DateHelper;
|
||||
use App\Models\Contact\Gender;
|
||||
use App\Models\Contact\Address;
|
||||
@@ -87,27 +89,26 @@ class ImportCSV extends Command
|
||||
|
||||
$first = true;
|
||||
$imported = 0;
|
||||
if (($handle = fopen($file, 'r')) !== false) {
|
||||
try {
|
||||
while (($data = fgetcsv($handle)) !== false) {
|
||||
// don't import the columns
|
||||
if ($first) {
|
||||
$first = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if first & last name do not exist skip row
|
||||
if (empty($data[1]) && empty($data[3])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->csvToContact($data, $user->account_id, $gender->id);
|
||||
|
||||
$imported++;
|
||||
try {
|
||||
$handle = fopen($file, 'r');
|
||||
while (($data = fgetcsv($handle)) !== false) {
|
||||
// don't import the columns
|
||||
if ($first) {
|
||||
$first = false;
|
||||
continue;
|
||||
}
|
||||
} finally {
|
||||
fclose($handle);
|
||||
|
||||
// if first & last name do not exist skip row
|
||||
if (empty($data[1]) && empty($data[3])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->csvToContact($data, $user->account_id, $gender->id);
|
||||
|
||||
$imported++;
|
||||
}
|
||||
} finally {
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
$this->info("Imported {$imported} Contacts");
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use function Safe\json_decode;
|
||||
use App\Models\Contact\Contact;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Instance\Instance;
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use function Safe\mkdir;
|
||||
use Illuminate\Console\Command;
|
||||
use function Safe\file_put_contents;
|
||||
use Illuminate\Console\ConfirmableTrait;
|
||||
use App\Console\Commands\Helpers\CommandExecutor;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use function Safe\touch;
|
||||
use App\Models\Account\Account;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use function Safe\unlink;
|
||||
|
||||
class ComposerScripts
|
||||
{
|
||||
const CONFIG = 'bootstrap/cache/config.php';
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Helpers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Jenssegers\Date\Date;
|
||||
use function Safe\strtotime;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use function Safe\json_decode;
|
||||
use App\Models\Account\Account;
|
||||
use function Safe\file_get_contents;
|
||||
|
||||
class InstanceHelper
|
||||
{
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace App\Helpers;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Matriphe\ISO639\ISO639;
|
||||
use function Safe\preg_match;
|
||||
use function Safe\preg_split;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use function Safe\preg_match;
|
||||
use App\Models\Contact\Contact;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\Contact\ContactFieldType;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Helpers;
|
||||
|
||||
use DateTimeZone;
|
||||
use function Safe\substr;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class TimezoneHelper
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use function Safe\substr;
|
||||
use Illuminate\Http\Request;
|
||||
use function Safe\json_decode;
|
||||
use App\Models\Account\ApiUsage;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Traits\JsonRespondController;
|
||||
@@ -65,11 +67,15 @@ class ApiController extends Controller
|
||||
// if the call contains a JSON, the call must not be a GET or
|
||||
// a DELETE
|
||||
// TODO: there is probably a much better way to do that
|
||||
if ($request->method() != 'GET' && $request->method() != 'DELETE'
|
||||
&& is_null(json_decode($request->getContent()))) {
|
||||
return $this->setHTTPStatusCode(400)
|
||||
->setErrorCode(37)
|
||||
->respondWithError();
|
||||
try {
|
||||
if ($request->method() != 'GET' && $request->method() != 'DELETE'
|
||||
&& is_null(json_decode($request->getContent()))) {
|
||||
return $this->setHTTPStatusCode(400)
|
||||
->setErrorCode(37)
|
||||
->respondWithError();
|
||||
}
|
||||
} catch (\Safe\Exceptions\JsonException $e) {
|
||||
// no error
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\Auth;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Models\User\User;
|
||||
use Illuminate\Http\Request;
|
||||
use function Safe\json_decode;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\User\User;
|
||||
use App\Helpers\DateHelper;
|
||||
use App\Models\Contact\Debt;
|
||||
use Illuminate\Http\Request;
|
||||
use function Safe\json_encode;
|
||||
use App\Helpers\InstanceHelper;
|
||||
use App\Models\Contact\Contact;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use function Safe\json_decode;
|
||||
use Lahaxearnaud\U2f\Models\U2fKey;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models\Account;
|
||||
|
||||
use App\Models\Contact\Contact;
|
||||
use function Safe\preg_replace;
|
||||
use App\Helpers\CountriesHelper;
|
||||
use App\Models\ModelBinding as Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -83,7 +84,10 @@ class Place extends Model
|
||||
}
|
||||
|
||||
// trim extra whitespaces inside the address
|
||||
return preg_replace('/\s+/', ' ', $address);
|
||||
$address = preg_replace('/\s+/', ' ', $address);
|
||||
if (is_string($address)) {
|
||||
return $address;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Helpers\WeatherHelper;
|
||||
use App\Models\Account\Account;
|
||||
use App\Models\Account\Weather;
|
||||
use App\Models\Account\Activity;
|
||||
use function Safe\preg_match_all;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Instance\SpecialDate;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Services\Instance\Geolocalization;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Account\Place;
|
||||
use App\Services\BaseService;
|
||||
use function Safe\json_decode;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use GuzzleHttp\Client as GuzzleClient;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Services\Instance\Weather;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Account\Place;
|
||||
use App\Services\BaseService;
|
||||
use function Safe\json_decode;
|
||||
use App\Models\Account\Weather;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use GuzzleHttp\Client as GuzzleClient;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Services\VCard;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use App\Models\User\User;
|
||||
use App\Traits\DAVFormat;
|
||||
use function Safe\substr;
|
||||
use Sabre\VObject\Reader;
|
||||
use App\Helpers\DateHelper;
|
||||
use Illuminate\Support\Arr;
|
||||
@@ -13,6 +14,7 @@ use App\Helpers\VCardHelper;
|
||||
use App\Helpers\LocaleHelper;
|
||||
use App\Helpers\RandomHelper;
|
||||
use App\Services\BaseService;
|
||||
use function Safe\preg_split;
|
||||
use App\Models\Contact\Gender;
|
||||
use App\Models\Contact\Address;
|
||||
use App\Models\Contact\Contact;
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
"sentry/sentry-laravel": "^1.0",
|
||||
"stevebauman/location": "^3.0",
|
||||
"symfony/translation": "^4.0",
|
||||
"thecodingmachine/safe": "^0.1.15",
|
||||
"vectorface/whip": "^0.3.2",
|
||||
"vinkla/hashids": "^6.0",
|
||||
"vluzrmos/language-detector": "^1.0"
|
||||
@@ -63,6 +64,7 @@
|
||||
"roave/security-advisories": "dev-master",
|
||||
"symfony/css-selector": "~4.0",
|
||||
"symfony/dom-crawler": "~4.0",
|
||||
"thecodingmachine/phpstan-safe-rule": "^0.1.3",
|
||||
"vimeo/psalm": "^3.0"
|
||||
},
|
||||
"suggest": {
|
||||
|
||||
Generated
+182
-2
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "355c5c3513701f90a328206efc87a7d5",
|
||||
"content-hash": "ef5ec4daa682acd3563f90150f93c78c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
@@ -7206,7 +7206,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Gert de Pagter",
|
||||
"email": "BackEndTea@gmail.com"
|
||||
"email": "backendtea@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for ctype functions",
|
||||
@@ -7949,6 +7949,138 @@
|
||||
],
|
||||
"time": "2014-11-11T03:54:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thecodingmachine/safe",
|
||||
"version": "v0.1.15",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thecodingmachine/safe.git",
|
||||
"reference": "9a4dbc54e397e0bfb152f4b38f8a03040a1e9e3e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thecodingmachine/safe/zipball/9a4dbc54e397e0bfb152f4b38f8a03040a1e9e3e",
|
||||
"reference": "9a4dbc54e397e0bfb152f4b38f8a03040a1e9e3e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^0.10.3",
|
||||
"squizlabs/php_codesniffer": "^3.2",
|
||||
"thecodingmachine/phpstan-strict-rules": "^0.10.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Safe\\": [
|
||||
"lib/",
|
||||
"generated/"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"generated/apache.php",
|
||||
"generated/apc.php",
|
||||
"generated/apcu.php",
|
||||
"generated/array.php",
|
||||
"generated/bzip2.php",
|
||||
"generated/classobj.php",
|
||||
"generated/com.php",
|
||||
"generated/cubrid.php",
|
||||
"generated/curl.php",
|
||||
"generated/datetime.php",
|
||||
"generated/dir.php",
|
||||
"generated/eio.php",
|
||||
"generated/errorfunc.php",
|
||||
"generated/exec.php",
|
||||
"generated/fileinfo.php",
|
||||
"generated/filesystem.php",
|
||||
"generated/filter.php",
|
||||
"generated/fpm.php",
|
||||
"generated/ftp.php",
|
||||
"generated/funchand.php",
|
||||
"generated/gmp.php",
|
||||
"generated/gnupg.php",
|
||||
"generated/hash.php",
|
||||
"generated/ibase.php",
|
||||
"generated/ibmDb2.php",
|
||||
"generated/iconv.php",
|
||||
"generated/image.php",
|
||||
"generated/imap.php",
|
||||
"generated/info.php",
|
||||
"generated/ingres-ii.php",
|
||||
"generated/inotify.php",
|
||||
"generated/json.php",
|
||||
"generated/ldap.php",
|
||||
"generated/libevent.php",
|
||||
"generated/libxml.php",
|
||||
"generated/lzf.php",
|
||||
"generated/mailparse.php",
|
||||
"generated/mbstring.php",
|
||||
"generated/misc.php",
|
||||
"generated/msql.php",
|
||||
"generated/mssql.php",
|
||||
"generated/mysql.php",
|
||||
"generated/mysqli.php",
|
||||
"generated/mysqlndMs.php",
|
||||
"generated/mysqlndQc.php",
|
||||
"generated/network.php",
|
||||
"generated/oci8.php",
|
||||
"generated/opcache.php",
|
||||
"generated/openssl.php",
|
||||
"generated/outcontrol.php",
|
||||
"generated/password.php",
|
||||
"generated/pcntl.php",
|
||||
"generated/pcre.php",
|
||||
"generated/pdf.php",
|
||||
"generated/pgsql.php",
|
||||
"generated/posix.php",
|
||||
"generated/ps.php",
|
||||
"generated/pspell.php",
|
||||
"generated/readline.php",
|
||||
"generated/rrd.php",
|
||||
"generated/sem.php",
|
||||
"generated/session.php",
|
||||
"generated/shmop.php",
|
||||
"generated/simplexml.php",
|
||||
"generated/sockets.php",
|
||||
"generated/sodium.php",
|
||||
"generated/solr.php",
|
||||
"generated/spl.php",
|
||||
"generated/sqlsrv.php",
|
||||
"generated/ssdeep.php",
|
||||
"generated/ssh2.php",
|
||||
"generated/stats.php",
|
||||
"generated/stream.php",
|
||||
"generated/strings.php",
|
||||
"generated/swoole.php",
|
||||
"generated/uodbc.php",
|
||||
"generated/uopz.php",
|
||||
"generated/url.php",
|
||||
"generated/var.php",
|
||||
"generated/xdiff.php",
|
||||
"generated/xml.php",
|
||||
"generated/xmlrpc.php",
|
||||
"generated/yaml.php",
|
||||
"generated/yaz.php",
|
||||
"generated/zip.php",
|
||||
"generated/zlib.php",
|
||||
"lib/special_cases.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "PHP core functions that throw exceptions instead of returning FALSE on error",
|
||||
"time": "2019-04-17T16:09:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tijsverkoyen/css-to-inline-styles",
|
||||
"version": "2.2.1",
|
||||
@@ -12627,6 +12759,54 @@
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2019-02-07T11:40:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "thecodingmachine/phpstan-safe-rule",
|
||||
"version": "v0.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thecodingmachine/phpstan-safe-rule.git",
|
||||
"reference": "00f4845905feb5240ca62fb799e3c51ba85c9230"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thecodingmachine/phpstan-safe-rule/zipball/00f4845905feb5240ca62fb799e3c51ba85c9230",
|
||||
"reference": "00f4845905feb5240ca62fb799e3c51ba85c9230",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1",
|
||||
"phpstan/phpstan": "^0.10 | ^0.11",
|
||||
"thecodingmachine/safe": "^0.1.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "^2.1",
|
||||
"phpunit/phpunit": "^7.5.2",
|
||||
"squizlabs/php_codesniffer": "^3.4"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"TheCodingMachine\\Safe\\PHPStan\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "David Négrier",
|
||||
"email": "d.negrier@thecodingmachine.com"
|
||||
}
|
||||
],
|
||||
"description": "A PHPStan rule to detect safety issues. Must be used in conjunction with thecodingmachine/safe",
|
||||
"time": "2019-03-07T13:52:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "theseer/fdomdocument",
|
||||
"version": "1.6.6",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use function Safe\json_decode;
|
||||
|
||||
$passports = [
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use function Safe\json_decode;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
use function Safe\json_decode;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Models\User\User;
|
||||
use function Safe\json_decode;
|
||||
use App\Models\Account\Account;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Helpers\CountriesHelper;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
includes:
|
||||
- ./vendor/nunomaduro/larastan/extension.neon
|
||||
- ./vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
|
||||
|
||||
parameters:
|
||||
level: 5
|
||||
ignoreErrors:
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
|
||||
<h3>{{ trans('auth.mfa_auth_u2f') }}</h3>
|
||||
<u2f-connector
|
||||
:authdatas="{{ json_encode($authenticationData) }}"
|
||||
:authdatas="{{ \Safe\json_encode($authenticationData) }}"
|
||||
:method="'login'"
|
||||
:callbackurl="{{ json_encode(url()->current()) }}">
|
||||
:callbackurl="{{ \Safe\json_encode(url()->current()) }}">
|
||||
</u2f-connector>
|
||||
|
||||
@if (app('pragmarx.google2fa')->isActivated())
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<link rel="shortcut icon" href="img/favicon.png">
|
||||
<script>
|
||||
window.Laravel = {!! json_encode([
|
||||
window.Laravel = {!! \Safe\json_encode([
|
||||
'csrfToken' => csrf_token(),
|
||||
'locale' => \App::getLocale(),
|
||||
'htmldir' => htmldir(),
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<link rel="stylesheet" href="{{ asset(mix('css/app-'.htmldir().'.css')) }}">
|
||||
<link rel="shortcut icon" href="img/favicon.png">
|
||||
<script>
|
||||
window.Laravel = {!! json_encode([
|
||||
window.Laravel = {!! \Safe\json_encode([
|
||||
'csrfToken' => csrf_token(),
|
||||
'locale' => \App::getLocale(),
|
||||
'htmldir' => htmldir(),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<h1 class="tc mb2 mt0">
|
||||
<span class="{{ htmldir() == 'ltr' ? 'mr1' : 'ml1' }}">{{ $contact->name }}</span>
|
||||
<contact-favorite hash="{{ $contact->hashID() }}" :starred="{{ json_encode($contact->is_starred) }}"></contact-favorite>
|
||||
<contact-favorite hash="{{ $contact->hashID() }}" :starred="{{ \Safe\json_encode($contact->is_starred) }}"></contact-favorite>
|
||||
</h1>
|
||||
|
||||
<ul class="tc-ns mb3 {{ htmldir() == 'ltr' ? 'tl' : 'tr' }}">
|
||||
@@ -63,7 +63,7 @@
|
||||
{{-- STAY IN TOUCH --}}
|
||||
<li class="mb2 mb0-ns di-ns db tc {{ htmldir() == 'ltr' ? 'mr3-ns' : 'ml3-ns' }}">
|
||||
@include('partials.icons.header_stayintouch')
|
||||
<stay-in-touch :contact="{{ $contact }}" hash="{{ $contact->hashID() }}" :limited="{{ json_encode(auth()->user()->account->hasLimitations()) }}"></stay-in-touch>
|
||||
<stay-in-touch :contact="{{ $contact }}" hash="{{ $contact->hashID() }}" :limited="{{ \Safe\json_encode(auth()->user()->account->hasLimitations()) }}"></stay-in-touch>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
@else
|
||||
|
||||
<document-list hash="{{ $contact->hashID() }}" reach-limit="{{ json_encode($contact->account->hasReachedAccountStorageLimit()) }}"></document-list>
|
||||
<document-list hash="{{ $contact->hashID() }}" reach-limit="{{ \Safe\json_encode($contact->account->hasReachedAccountStorageLimit()) }}"></document-list>
|
||||
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
:day="{{ $day }}"
|
||||
:age="'{{ $age }}'"
|
||||
:default-date="'{{ $birthdate }}'"
|
||||
:reminder="{{ json_encode($hasBirthdayReminder) }}"
|
||||
:reminder="{{ \Safe\json_encode($hasBirthdayReminder) }}"
|
||||
:value="'{{ $birthdayState }}'"
|
||||
></form-specialdate>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
hash="{{ $contact->hashID() }}"
|
||||
contact-name="{{ $contact->first_name }}"
|
||||
current-photo-id-as-avatar="{{ $contact->avatar_photo_id }}"
|
||||
reach-limit="{{ json_encode($contact->account->hasReachedAccountStorageLimit()) }}">
|
||||
reach-limit="{{ \Safe\json_encode($contact->account->hasReachedAccountStorageLimit()) }}">
|
||||
</photo-list>
|
||||
</div>
|
||||
</div>
|
||||
@@ -65,7 +65,7 @@
|
||||
<a href="{{ route('people.vcard', $contact) }}">{{ trans('people.people_export') }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<contact-archive hash="{{ $contact->hashID() }}" :active="{{ json_encode($contact->is_active) }}"></contact-archive>
|
||||
<contact-archive hash="{{ $contact->hashID() }}" :active="{{ \Safe\json_encode($contact->is_active) }}"></contact-archive>
|
||||
</li>
|
||||
<li>
|
||||
<a id="link-delete-contact" class="pointer" onclick="if (confirm('{{ trans('people.people_delete_confirmation') }}')) { $('#contact-delete-form').submit(); } return false;">{{ trans('people.people_delete_message') }}</a>
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
:day="{{ $day }}"
|
||||
:age="'{{ $age }}'"
|
||||
:default-date="'{{ $birthdate }}'"
|
||||
:reminder="{{ json_encode($hasBirthdayReminder) }}"
|
||||
:reminder="{{ \Safe\json_encode($hasBirthdayReminder) }}"
|
||||
:value="'{{ $birthdayState }}'"
|
||||
></form-specialdate>
|
||||
|
||||
|
||||
@@ -112,8 +112,8 @@
|
||||
<reminder-time
|
||||
:reminder="'{{ auth()->user()->account->default_time_reminder_is_sent }}'"
|
||||
:timezone="'{{ $selectedTimezone }}'"
|
||||
:timezones="{{ json_encode($timezones) }}"
|
||||
:hours="{{ json_encode($hours) }}">
|
||||
:timezones="{{ \Safe\json_encode($timezones) }}"
|
||||
:hours="{{ \Safe\json_encode($hours) }}">
|
||||
</reminder-time>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -57,13 +57,13 @@
|
||||
|
||||
<div class="br3 ba b--gray-monica bg-white mb4">
|
||||
<div class="pa3 bb b--gray-monica">
|
||||
<activity-types :limited="{{ json_encode(auth()->user()->account->hasLimitations()) }}"></activity-types>
|
||||
<activity-types :limited="{{ \Safe\json_encode(auth()->user()->account->hasLimitations()) }}"></activity-types>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="br3 ba b--gray-monica bg-white mb4">
|
||||
<div class="pa3 bb b--gray-monica">
|
||||
<modules :limited="{{ json_encode(auth()->user()->account->hasLimitations()) }}"></modules>
|
||||
<modules :limited="{{ \Safe\json_encode(auth()->user()->account->hasLimitations()) }}"></modules>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
@if (config('google2fa.enabled')===true)
|
||||
<mfa-activate
|
||||
:activated="{{ json_encode($is2FAActivated) }}"
|
||||
:activated="{{ \Safe\json_encode($is2FAActivated) }}"
|
||||
>
|
||||
</mfa-activate>
|
||||
@endif
|
||||
@@ -82,8 +82,8 @@
|
||||
@if (config('u2f.enable')===true)
|
||||
<u2f-connector
|
||||
:method="'register-modal'"
|
||||
:currentkeys="{{ json_encode($currentkeys) }}"
|
||||
:timezone="{{ json_encode(auth()->user()->timezone) }}">
|
||||
:currentkeys="{{ \Safe\json_encode($currentkeys) }}"
|
||||
:timezone="{{ \Safe\json_encode(auth()->user()->timezone) }}">
|
||||
</u2f-connector>
|
||||
<script src="{{ asset(mix('js/u2f-api.js')) }}" type="text/javascript"></script>
|
||||
@endif
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
<p>{{ trans('settings.u2f_enable_description') }}</p>
|
||||
|
||||
<u2f-connector
|
||||
:currentkeys="{{ json_encode($currentKeys) }}"
|
||||
:registerdata="{{ json_encode($registerData) }}"
|
||||
:currentkeys="{{ \Safe\json_encode($currentKeys) }}"
|
||||
:registerdata="{{ \Safe\json_encode($registerData) }}"
|
||||
:method="'register'"
|
||||
:callbackurl="{{ json_encode(route('security.index')) }}">
|
||||
:callbackurl="{{ \Safe\json_encode(route('security.index')) }}">
|
||||
</u2f-connector>
|
||||
|
||||
<a href="{{ route('security.index') }}" class="btn">{{ trans('app.cancel') }}</a>
|
||||
|
||||
@@ -118,11 +118,8 @@ class ApiUserControllerTest extends ApiTestCase
|
||||
|
||||
$response = $this->post('/api/me/compliance');
|
||||
|
||||
$response->assertStatus(400);
|
||||
|
||||
$response->assertJsonFragment([
|
||||
'error_code' => 37,
|
||||
'message' => 'Problems parsing JSON',
|
||||
$this->expectDataError($response, [
|
||||
'The ip address field is required.',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ class ApiLifeEventControllerTest extends ApiTestCase
|
||||
|
||||
$response = $this->json('POST', '/api/lifeevents', [
|
||||
'contact_id' => $contact->id,
|
||||
'life_event_type_id' => 392029834029,
|
||||
'life_event_type_id' => 0,
|
||||
'happened_at' => '1989-02-02',
|
||||
'name' => 'This is a text',
|
||||
'note' => 'This is a text',
|
||||
@@ -189,7 +189,7 @@ class ApiLifeEventControllerTest extends ApiTestCase
|
||||
]);
|
||||
|
||||
$response = $this->json('POST', '/api/lifeevents', [
|
||||
'contact_id' => 9320984209,
|
||||
'contact_id' => 0,
|
||||
'life_event_type_id' => $lifeEventType->id,
|
||||
'happened_at' => '1989-02-02',
|
||||
'name' => 'This is a text',
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Commands;
|
||||
|
||||
use Mockery as m;
|
||||
use Tests\TestCase;
|
||||
use App\Models\User\User;
|
||||
use App\Models\Account\Account;
|
||||
use App\Models\Contact\Contact;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class ImportCSVTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_csv_import_contacts()
|
||||
{
|
||||
$this->withoutMockingConsoleOutput();
|
||||
Storage::fake('public');
|
||||
|
||||
$user = $this->getUser();
|
||||
$path = base_path('tests/stubs/single_contact_stub.csv');
|
||||
|
||||
$totalContacts = Contact::where('account_id', $user->account_id)->count();
|
||||
|
||||
$exitCode = $this->artisan('import:csv '.$user->email.' '.$path);
|
||||
|
||||
$this->assertDatabaseHas('contacts', [
|
||||
'first_name' => 'Bono',
|
||||
'last_name' => 'Hewson',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('contact_fields', [
|
||||
'data' => 'bono@example.com',
|
||||
]);
|
||||
|
||||
// Allows checking if birthday was correctly set
|
||||
$this->assertDatabaseHas('special_dates', [
|
||||
'date' => '1960-05-10',
|
||||
]);
|
||||
|
||||
// Asserts that only 3 new contacts were created
|
||||
$this->assertEquals(
|
||||
$totalContacts + 1,
|
||||
Contact::where('account_id', $user->account_id)->count()
|
||||
);
|
||||
|
||||
$this->assertEquals(0, $exitCode);
|
||||
}
|
||||
|
||||
public function test_csv_import_validates_user()
|
||||
{
|
||||
$this->withoutMockingConsoleOutput();
|
||||
|
||||
$path = base_path('tests/stubs/single_contact_stub.csv');
|
||||
|
||||
$command = m::mock('\App\Console\Commands\ImportCSV[error]', [new \Illuminate\Filesystem\Filesystem()]);
|
||||
|
||||
$command->shouldReceive('error')->once()->with('You need to provide a valid User ID or email address!');
|
||||
|
||||
$this->app['Illuminate\Contracts\Console\Kernel']->registerCommand($command);
|
||||
|
||||
$exitCode = $this->artisan('import:csv test@test.com '.$path);
|
||||
|
||||
$this->assertEquals(-1, $exitCode);
|
||||
}
|
||||
|
||||
public function test_csv_import_validates_file()
|
||||
{
|
||||
$this->withoutMockingConsoleOutput();
|
||||
|
||||
$user = $this->getUser();
|
||||
|
||||
$command = m::mock('\App\Console\Commands\ImportCSV[error]', [new \Illuminate\Filesystem\Filesystem()]);
|
||||
|
||||
$command->shouldReceive('error')->once()->with('You need to provide a valid file path.');
|
||||
|
||||
$this->app['Illuminate\Contracts\Console\Kernel']->registerCommand($command);
|
||||
|
||||
$exitCode = $this->artisan('import:csv '.$user->email.' xxx');
|
||||
|
||||
$this->assertEquals(-1, $exitCode);
|
||||
}
|
||||
|
||||
private function getUser()
|
||||
{
|
||||
$account = Account::createDefault('John', 'Doe', 'johndoe@example.com', 'secret');
|
||||
|
||||
return $account->users()->first();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Unit\Helpers;
|
||||
|
||||
use Tests\TestCase;
|
||||
use function Safe\json_decode;
|
||||
use App\Helpers\InstanceHelper;
|
||||
use App\Models\Account\Account;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
id,first_name,middle_name,last_name
|
||||
0,Bono,Paul David,Hewson,,,,,,,,,,,1960-05-10,,,,,,,,,,,,,,bono@example.com
|
||||
|
Reference in New Issue
Block a user