mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Align Signup and Login responses for consistency
This commit is contained in:
parent
feff6a1c76
commit
9effc2ebca
57
app/Events/Contact/ContactLoggedIn.php
Normal file
57
app/Events/Contact/ContactLoggedIn.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Events\Contact;
|
||||
|
||||
use App\Models\ClientContact;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UserLoggedIn
|
||||
* @package App\Events\User
|
||||
*/
|
||||
class ContactLoggedIn
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var $client_contact
|
||||
*/
|
||||
public $client_contact;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ClientContact $client_contact)
|
||||
{
|
||||
|
||||
$this->client_contact = $client_contact;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
@ -86,6 +86,8 @@ class LoginController extends BaseController
|
||||
*/
|
||||
public function apiLogin(Request $request)
|
||||
{
|
||||
$this->forced_includes = ['company_users'];
|
||||
|
||||
$this->validateLogin($request);
|
||||
|
||||
if ($this->hasTooManyLoginAttempts($request)) {
|
||||
|
@ -141,13 +141,13 @@ class MultiDB
|
||||
|
||||
}
|
||||
|
||||
public static function findAndSetDbByDomain($host) :bool
|
||||
public static function findAndSetDbByDomain($domain) :bool
|
||||
{
|
||||
|
||||
foreach (self::$dbs as $db)
|
||||
{
|
||||
|
||||
if($company = Company::on($db)->whereDomain($host)->first())
|
||||
if($company = Company::on($db)->whereDomain($domain)->first())
|
||||
{
|
||||
|
||||
self::setDb($company->db);
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\CompanyToken;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class CompanyUser extends Pivot
|
||||
|
@ -156,6 +156,14 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
return $this->hasMany(CompanyUser::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias of user_companies()
|
||||
*/
|
||||
public function company_users()
|
||||
{
|
||||
return $this->user_companies();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current company by
|
||||
* querying directly on the pivot table relationship
|
||||
|
@ -52,8 +52,8 @@ class UserTransformer extends EntityTransformer
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultIncludes = [
|
||||
// 'company_token',
|
||||
// 'token',
|
||||
//'company_users',
|
||||
// 'token',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -61,6 +61,7 @@ class UserTransformer extends EntityTransformer
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'companies',
|
||||
'company_users',
|
||||
];
|
||||
|
||||
|
||||
@ -82,15 +83,6 @@ class UserTransformer extends EntityTransformer
|
||||
];
|
||||
}
|
||||
|
||||
public function includeUserCompany(User $user)
|
||||
{
|
||||
|
||||
$transformer = new CompanyUserTransformer($this->serializer);
|
||||
|
||||
return $this->includeItem($user->user_company(), $transformer, CompanyUser::class);
|
||||
|
||||
}
|
||||
|
||||
public function includeCompanies(User $user)
|
||||
{
|
||||
|
||||
@ -117,4 +109,13 @@ class UserTransformer extends EntityTransformer
|
||||
return $this->includeCollection($user->tokens, $transformer, CompanyToken::class);
|
||||
|
||||
}
|
||||
|
||||
public function includeCompanyUsers(User $user)
|
||||
{
|
||||
|
||||
$transformer = new CompanyUserTransformer($this->serializer);
|
||||
|
||||
return $this->includeCollection($user->user_companies, $transformer, CompanyUser::class);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,15 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
|
||||
Route::group(['middleware' => ['api_secret_check']], function () {
|
||||
|
||||
Route::post('api/v1/signup', 'AccountController@store')->name('signup.submit');
|
||||
Route::post('api/v1/login', 'Auth\LoginController@apiLogin')->name('login.submit');
|
||||
Route::post('api/v1/oauth_login', 'Auth\LoginController@oauthApiLogin');
|
||||
|
||||
});
|
||||
|
||||
Route::group(['api_secret_check','domain_db'], function () {
|
||||
|
||||
Route::post('api/v1/login', 'Auth\LoginController@apiLogin')->name('login.submit');
|
||||
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['db','api_secret_check','token_auth'], 'prefix' =>'api/v1', 'as' => 'api.'], function () {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user