Display initial user and site configuration page.

@param  object  $listener

@return mixed
434770
public function create($listener)
    {
        $model = new Fluent([
            'site' => ['name' => \config('app.name', 'Orchestra Platform')],
        ]);

        $form = $this->presenter->form($model);

        return $listener->createSucceed(\compact('form', 'model'));
    }
245434
public function enable(UserConfigurationListener $listener, User $user, AreaContract $area)
    {
        try {
            $userConfig = $this->getUserConfig($user, $area);

            $this->userConfigRepository->markAsEnabledById($userConfig->id);

            if ($this->isConfigured($area)) {
                $msg = trans('antares/two_factor_auth::configuration.responses.enable.success', ['area' => $area->getLabel()]);
                return $listener->afterConfiguration($area, $msg);
            }

            return $this->configure($listener, $area);
        } catch (Exception $e) {
            Log::emergency($e);

            $msg = trans('antares/two_factor_auth::configuration.responses.enable.fail', ['area' => $area->getLabel()]);

            return $listener->enableFailed($msg);
        }
    }
443111
public function prepare($listener)
    {
        if (! $this->requirements->check()) {
            return $listener->preparationNotCompleted();
        }

        $this->installer->migrate();

        return $listener->preparationCompleted();
    }
193931
public function resource(Presenter $listener = null, $url, Model $model, array $attributes = [])
    {
        $method = 'POST';
        if ($model->exists) {
            $last = last(explode('/', $url));
            if (!is_numeric($last)) {
                $url = "{$url}/{$model->getKey()}";
            }
            $method = 'PUT';
        }
        $attributes['method'] = $method;

        return $this->setup($listener, $url, $model, $attributes);
    }
1270832
public function index($listener)
    {
        $eloquent = $this->model->newQuery();
        $table = $this->presenter->table($eloquent);

        $this->fireEvent('list', [$eloquent, $table]);

        // Once all event listening to `orchestra.list: role` is executed,
        // we can add we can now add the final column, edit and delete
        // action for roles.
        $this->presenter->actions($table);

        return $listener->indexSucceed(compact('eloquent', 'table'));
    }
1064235
public function index(ViewListener $listener)
    {
        $form = $this->presenter->form();
        return $listener->show(compact('form'));
    }
222798
public function update(ConfigurationUpdaterListener $listener, array $input)
    {
        try {

            foreach (array_get($input, 'drivers', []) as $driver => $config) {
                $this->authProviderService->updateDriver($driver, $config);
                event('api.driver.' . $driver . '.update', [$input, $this->authProviderService]);
            }

            $this->authProviderService->save();
        } catch (Exception $e) {
            Log::emergency($e);
            return $listener->updateAuthFailed(['error' => $e->getMessage()]);
        }

        return $listener->authUpdated();
    }
243993
public function getUser()
    {
        if ($user = $this->provider->getUser()) {
            return ($field = $this->field) ? (string) $user->{$field} : $user->getLogin();
        }
    }
1179906
function findListener($listener)
    {
        if (is_string($listener))
            return (isset($this->_c_listeners[$listener])) ? $this->_c_listeners[$listener] : false;
        elseif (is_object($listener)) {
            foreach (clone $this->_listenerQueue() as $l) {
                if ($l === $listener)
                    return $listener;
            }
        }
        
        return false;
    }
12191
public function configure(UserConfigurationListener $listener, AreaContract $area)
    {
        $provider   = $this->twoFactorProvidersService->getEnabledInArea($area);
        $userConfig = $this->userConfigService->saveConfig($provider);


        $form = $this->presenter->configure($userConfig, $area, $provider);

        $this->dispatcher->fire('antares.form: two_factor_auth', [$provider, $form]);

        return $listener->showConfiguration($provider, $form);
    }
1353739
public function showByType(Selector $listener, string $type)
    {
        if (! in_array($type, $this->type)) {
            return $listener->themeFailedVerification();
        }

        $current = $this->memory->get("site.theme.{$type}");
        $themes = $this->getAvailableTheme($type);

        return $listener->showThemeSelection(compact('current', 'themes', 'type'));
    }
1344618
public function edit($listener, $metric)
    {
        $collection = [];
        $instances = $this->acl->all();
        $eloquent = null;

        foreach ($instances as $name => $instance) {
            $collection[$name] = (string) $this->getAuthorizationName($name);

            $name === $metric && $eloquent = $instance;
        }

        if (is_null($eloquent)) {
            return $listener->aclVerificationFailed();
        }

        $actions = $this->getAuthorizationActions($eloquent, $metric);
        $roles = $this->getAuthorizationRoles($eloquent);

        return $listener->indexSucceed(compact('actions', 'roles', 'eloquent', 'collection', 'metric'));
    }
169558
public function markAsConfigured(UserConfigurationListener $listener, AreaContract $area)
    {

        $service    = app(TwoFactorProvidersService::class);
        $service->bind();
        $provider   = $service->getEnabledInArea($area);
        $userConfig = $this->userConfigService->getSettingsByArea($area);
        $secretKey  = $userConfig->settings['secret_key'];
        $form       = app(\Antares\Modules\TwoFactorAuth\Http\Presenters\AuthPresenter::class)->verify($userConfig, $area, $provider, $secretKey);


        return $listener->afterConfiguration($form);
    }
1244810
public function createClassListener($listener)
    {
        return function ($event, $payload) use ($listener) {
            return call_user_func_array($this->createClassCallable($listener), $payload);
        };
    }
740331
public function verify(AuthListener $listener, AreaContract $area)
    {
        $provider   = $this->service->getEnabledInArea($area);
        $userConfig = $this->userConfigService->getSettingsByArea($area);
        $form       = $this->presenter->verify($userConfig, $area, $provider);

        return $listener->showVerifyForm($provider, $form);
    }
977903
public function createClassListener($listener)
	{
		$container = $this->container;

		return function() use ($listener, $container)
		{
			// If the listener has an @ sign, we will assume it is being used to delimit
			// the class name from the handle method name. This allows for handlers
			// to run multiple handler methods in a single class for convenience.
			$segments = explode('@', $listener);

			$method = count($segments) == 2 ? $segments[1] : 'handle';

			$callable = array($container->make($segments[0]), $method);

			// We will make a callable of the listener instance and a method that should
			// be called on that instance, then we will pass in the arguments that we
			// received in this method into this listener class instance's methods.
			$data = func_get_args();

			return call_user_func_array($callable, $data);
		};
	}
1125902
public function update($listener, array $input, $id)
    {
        if ((int) $id !== (int) $input['id']) {
            return $listener->userVerificationFailed();
        }

        $validation = $this->validator->on('update')->bind(['roleID' => $id])->with($input);

        if ($validation->fails()) {
            return $listener->updateValidationFailed($validation, $id);
        }

        $role = $this->model->findOrFail($id);

        try {
            $this->saving($role, $input, 'update');
        } catch (Exception $e) {
            return $listener->updateFailed(['error' => $e->getMessage()]);
        }

        return $listener->updateSucceed($role);
    }