mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
working on testing signup routes again
This commit is contained in:
parent
67fa34fe82
commit
518d5f12e7
@ -54,6 +54,7 @@ class BaseController extends Controller
|
|||||||
|
|
||||||
private function buildManager()
|
private function buildManager()
|
||||||
{
|
{
|
||||||
|
$include = '';
|
||||||
|
|
||||||
if(request()->input('include') !== null)
|
if(request()->input('include') !== null)
|
||||||
{
|
{
|
||||||
@ -65,17 +66,12 @@ class BaseController extends Controller
|
|||||||
$include = implode(",", $include);
|
$include = implode(",", $include);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else if(count($this->forced_includes) >= 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(count($this->forced_includes)>=1)
|
$include = implode(",", $this->forced_includes);
|
||||||
$include = implode(",", $this->forced_includes);
|
|
||||||
else
|
|
||||||
$include = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::error('forced includes = ' . print_r($this->forced_includes,1));
|
}
|
||||||
Log::error('includes = ' . $include);
|
|
||||||
|
|
||||||
$this->manager->parseIncludes($include);
|
$this->manager->parseIncludes($include);
|
||||||
|
|
||||||
@ -86,7 +82,8 @@ class BaseController extends Controller
|
|||||||
|
|
||||||
$this->manager->setSerializer(new JsonApiSerializer());
|
$this->manager->setSerializer(new JsonApiSerializer());
|
||||||
|
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->manager->setSerializer(new ArraySerializer());
|
$this->manager->setSerializer(new ArraySerializer());
|
||||||
|
@ -107,6 +107,19 @@ class CompanyController extends BaseController
|
|||||||
'settings' => json_encode(DefaultSettings::userSettings()),
|
'settings' => json_encode(DefaultSettings::userSettings()),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Required dependencies
|
||||||
|
*/
|
||||||
|
if($user)
|
||||||
|
auth()->login($user, false);
|
||||||
|
|
||||||
|
$user->setCompany($company);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create token
|
||||||
|
*/
|
||||||
|
$company_token = CreateCompanyToken::dispatchNow($company, auth()->user());
|
||||||
|
|
||||||
return $this->itemResponse($company);
|
return $this->itemResponse($company);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,9 @@ class CreateAccount
|
|||||||
|
|
||||||
public function __construct(array $request)
|
public function __construct(array $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,6 +70,14 @@ class CreateAccount
|
|||||||
*/
|
*/
|
||||||
$user = CreateUser::dispatchNow($this->request, $account, $company, true); //make user company_owner
|
$user = CreateUser::dispatchNow($this->request, $account, $company, true); //make user company_owner
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Required dependencies
|
||||||
|
*/
|
||||||
|
if($user)
|
||||||
|
auth()->login($user, false);
|
||||||
|
|
||||||
|
$user->setCompany($company);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create token
|
* Create token
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,7 @@ use App\DataMapper\CompanySettings;
|
|||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\AccountGateway;
|
use App\Models\AccountGateway;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\CompanyUser;
|
||||||
use App\Models\Country;
|
use App\Models\Country;
|
||||||
use App\Models\Currency;
|
use App\Models\Currency;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
@ -67,7 +68,7 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
public function users()
|
public function users()
|
||||||
{
|
{
|
||||||
return $this->hasMany(User::class);
|
return $this->hasMany(CompanyUser::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,7 +94,8 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
*/
|
*/
|
||||||
public function token()
|
public function token()
|
||||||
{
|
{
|
||||||
return $this->hasOne(CompanyToken::class)->orderBy('id', 'ASC');
|
return $this->tokens->whereCompanyId($this->company()->id)->first();
|
||||||
|
//return $this->hasOne(CompanyToken::class)->orderBy('id', 'ASC');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,7 +105,7 @@ class UserTransformer extends EntityTransformer
|
|||||||
|
|
||||||
$transformer = new CompanyTokenTransformer($this->serializer);
|
$transformer = new CompanyTokenTransformer($this->serializer);
|
||||||
|
|
||||||
return $this->includeItem($user->token, $transformer, CompanyToken::class);
|
return $this->includeItem($user->token(), $transformer, CompanyToken::class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ class ClientTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'name' => $this->faker->company,
|
'name' => $this->faker->company,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
@ -87,8 +87,8 @@ class ClientTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'name' => $this->faker->company,
|
'name' => $this->faker->company,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
|
@ -124,7 +124,7 @@ class RecurringInvoiceTest extends TestCase
|
|||||||
])->post('/api/v1/signup', $data);
|
])->post('/api/v1/signup', $data);
|
||||||
|
|
||||||
$acc = $response->json();
|
$acc = $response->json();
|
||||||
|
Log::error($acc);
|
||||||
$account = Account::find($this->decodePrimaryKey($acc['data']['id']));
|
$account = Account::find($this->decodePrimaryKey($acc['data']['id']));
|
||||||
|
|
||||||
$company_token = $account->default_company->tokens()->first();
|
$company_token = $account->default_company->tokens()->first();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user