Respect home hubs setting for registration #580 (#581)

Respect home hubs setting for registration #580
This commit is contained in:
Nabeel S
2020-02-23 17:21:26 -05:00
committed by GitHub
parent b34dc4868e
commit a1d6fa17ad
11 changed files with 62 additions and 64 deletions

View File

@@ -17,6 +17,7 @@ use App\Repositories\AircraftRepository;
use App\Repositories\SubfleetRepository;
use App\Repositories\UserRepository;
use App\Support\Units\Time;
use App\Support\Utils;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use function is_array;
@@ -48,15 +49,19 @@ class UserService extends Service
* Register a pilot. Also attaches the initial roles
* required, and then triggers the UserRegistered event
*
* @param User $user User model
* @param array $attrs Array with the user data
* @param array $roles List of "display_name" of groups to assign
*
* @throws \Exception
*
* @return mixed
* @return User
*/
public function createUser(User $user, array $roles = null)
public function createUser(array $attrs, array $roles = null): User
{
$user = User::create($attrs);
$user->api_key = Utils::generateApiKey();
$user->curr_airport_id = $user->home_airport_id;
// Determine if we want to auto accept
if (setting('pilots.auto_accept') === true) {
$user->state = UserState::ACTIVE;