/** * Attempt to login the specified user. * * @return \Illuminate\Http\Response */ public function postLogin() { $remember = Binput::get('rememberMe'); $input = Binput::only(['email', 'password']); $rules = UserRepository::rules(array_keys($input)); $rules['password'] = '******'; $val = UserRepository::validate($input, $rules, true); if ($val->fails()) { return Redirect::route('account.login')->withInput()->withErrors($val->errors()); } $this->throttler->hit(); try { $throttle = Credentials::getThrottleProvider()->findByUserLogin($input['email']); $throttle->check(); Credentials::authenticate($input, $remember); } catch (WrongPasswordException $e) { return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'Your password was incorrect.'); } catch (UserNotFoundException $e) { return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'That user does not exist.'); } catch (UserNotActivatedException $e) { if (Config::get('credentials::activation')) { return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'You have not yet activated this account.'); } else { $throttle->user->attemptActivation($throttle->user->getActivationCode()); $throttle->user->addGroup(Credentials::getGroupProvider()->findByName('Users')); return $this->postLogin(); } } catch (UserSuspendedException $e) { $time = $throttle->getSuspensionTime(); return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', "Your account has been suspended for {$time} minutes."); } catch (UserBannedException $e) { return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'You have been banned. Please contact support.'); } return Redirect::intended(Config::get('core.home', '/')); }
/** * Attempt to register a new user. * * @return \Illuminate\Http\Response */ public function postRegister() { if (!Config::get('credentials.regallowed')) { return Redirect::route('account.register'); } $input = Binput::only(['first_name', 'last_name', 'email', 'password', 'password_confirmation']); $val = UserRepository::validate($input, array_keys($input)); if ($val->fails()) { return Redirect::route('account.register')->withInput()->withErrors($val->errors()); } $this->throttler->hit(); try { unset($input['password_confirmation']); $user = Credentials::register($input); if (!Config::get('credentials.activation')) { $mail = ['url' => URL::to(Config::get('credentials.home', '/')), 'email' => $user->getLogin(), 'subject' => Config::get('app.name') . ' - Welcome']; Mail::queue('credentials::emails.welcome', $mail, function ($message) use($mail) { $message->to($mail['email'])->subject($mail['subject']); }); $user->attemptActivation($user->getActivationCode()); $user->addGroup(Credentials::getGroupProvider()->findByName('Users')); return Redirect::to(Config::get('credentials.home', '/'))->with('success', 'Your account has been created successfully. You may now login.'); } $code = $user->getActivationCode(); $mail = ['url' => URL::to(Config::get('credentials.home', '/')), 'link' => URL::route('account.activate', ['id' => $user->id, 'code' => $code]), 'email' => $user->getLogin(), 'subject' => Config::get('app.name') . ' - Welcome']; Mail::queue('credentials::emails.welcome', $mail, function ($message) use($mail) { $message->to($mail['email'])->subject($mail['subject']); }); return Redirect::to(Config::get('credentials.home', '/'))->with('success', 'Your account has been created. Check your email for the confirmation link.'); } catch (UserExistsException $e) { return Redirect::route('account.register')->withInput()->withErrors($val->errors())->with('error', 'That email address is taken.'); } }
/** * Update an existing incident. * * @param \CachetHQ\Cachet\Models\Inicdent $incident * * @return \CachetHQ\Cachet\Models\Incident */ public function putIncident(Incident $incident) { $incident->update(Binput::all()); if ($incident->isValid('updating')) { return $this->item($incident); } throw new BadRequestHttpException(); }
/** * Updates the order of project teams. * * @return array */ public function postUpdateProjectTeamOrder() { $teamData = Binput::get('ids'); foreach ($teamData as $order => $teamId) { ProjectTeam::find($teamId)->update(['order' => $order + 1]); } return $teamData; }
/** * Returns a template by slug. * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * * @return \CachetHQ\Cachet\Models\IncidentTemplate */ public function getIncidentTemplate() { $templateSlug = Binput::get('slug'); if ($template = IncidentTemplate::where('slug', $templateSlug)->first()) { return $template; } throw new ModelNotFoundException("Incident template for {$templateSlug} could not be found."); }
/** * Update an existing metric. * * @param \CachetHQ\Cachet\Models\Metric $metric * * @return \CachetHQ\Cachet\Models\Metric */ public function putMetric(Metric $metric) { $metric->update(Binput::all()); if ($metric->isValid('updating')) { return $this->item($metric); } throw new BadRequestHttpException(); }
/** * Logs the user in. * * @return \Illuminate\Http\RedirectResponse */ public function postLogin() { if (Auth::attempt(Binput::only(['email', 'password']))) { return Redirect::intended('dashboard'); } Throttle::hit(Request::instance(), 10, 10); return Redirect::back()->withInput(Binput::except('password'))->with('error', 'Invalid email or password'); }
/** * Update an existing incident. * * @param \CachetHQ\Cachet\Models\Inicdent $incident * * @return \Illuminate\Http\JsonResponse */ public function putIncident(Incident $incident) { try { $incident->update(Binput::all()); } catch (Exception $e) { throw new BadRequestHttpException(); } return $this->item($incident); }
/** * Update an existing team. * * @param \Gitamin\Models\ProjectTeam $team * * @return \Illuminate\Http\JsonResponse */ public function putTeam(ProjectTeam $team) { try { $team = $this->dispatch(new UpdateProjectTeamCommand($team, Binput::get('name'), Binput::get('slug'), Binput::get('order', 0))); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($team); }
/** * Update an existing metric. * * @param \CachetHQ\Cachet\Models\Metric $metric * * @return \Illuminate\Http\JsonResponse */ public function putMetric(Metric $metric) { try { $metric = dispatch(new UpdateMetricCommand($metric, Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type'), Binput::get('display_chart'), Binput::get('places'), Binput::get('default_view', Binput::get('view')), Binput::get('threshold'), Binput::get('order'))); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($metric); }
/** * Update an existing issue. * * @param \Gitamin\Models\Inicdent $issue * * @return \Illuminate\Http\JsonResponse */ public function putIssue(Issue $issue) { try { $issue = $this->dispatch(new UpdateIssueCommand($issue, Binput::get('name'), Binput::get('status'), Binput::get('message'), Binput::get('visible', true), Binput::get('user_id'), Binput::get('project_id'), Binput::get('notify', true), Binput::get('created_at'))); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($issue); }
/** * Update an existing metric. * * @param \CachetHQ\Cachet\Models\Metric $metric * * @return \Illuminate\Http\JsonResponse */ public function putMetric(Metric $metric) { try { $metric = $this->dispatch(new UpdateMetricCommand($metric, Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type', 0), Binput::get('display_chart'), Binput::get('places', 2))); } catch (Exception $e) { throw new BadRequestHttpException(); } return $this->item($metric); }
/** * Create a new subscriber. * * @return \Illuminate\Http\JsonResponse */ public function postSubscribers() { try { $subscriber = $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email'), Binput::get('verify', false))); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($subscriber); }
/** * Update an existing incident. * * @param \CachetHQ\Cachet\Models\Inicdent $incident * * @return \Illuminate\Http\JsonResponse */ public function putIncident(Incident $incident) { try { $incident = $this->dispatch(new UpdateIncidentCommand($incident, Binput::get('name'), Binput::get('status'), Binput::get('message'), Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true), Binput::get('created_at'), Binput::get('template'), Binput::get('vars'))); } catch (Exception $e) { throw new BadRequestHttpException(); } return $this->item($incident); }
/** * Update an existing group. * * @param \CachetHQ\Cachet\Models\ComponentGroup $group * * @return \Illuminate\Http\JsonResponse */ public function putGroup(ComponentGroup $group) { try { $group = $this->dispatch(new UpdateComponentGroupCommand($group, Binput::get('name'), Binput::get('order', 0))); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($group); }
/** * Handle the subscribe user. * * @return \Illuminate\View\View */ public function postSubscribe() { try { $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email'))); } catch (ValidationException $e) { return Redirect::route('subscribe.subscribe')->withInput(Binput::all())->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('gitamin.subscriber.email.failure')))->withErrors($e->getMessageBag()); } return Redirect::route('explore')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('gitamin.subscriber.email.subscribed'))); }
/** * Creates a new subscriber. * * @return \Illuminate\Http\RedirectResponse */ public function createSubscriberAction() { try { dispatch(new SubscribeSubscriberCommand(Binput::get('email'))); } catch (ValidationException $e) { return Redirect::route('dashboard.subscribers.add')->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))->withErrors($e->getMessageBag()); } return Redirect::route('dashboard.subscribers.add')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success'))); }
/** * Update an existing metric. * * @param \CachetHQ\Cachet\Models\Metric $metric * * @return \Illuminate\Http\JsonResponse */ public function putMetric(Metric $metric) { try { $metric->update(Binput::all()); } catch (Exception $e) { throw new BadRequestHttpException(); } return $this->item($metric); }
/** * Handle the subscribe user. * * @return \Illuminate\View\View */ public function postSubscribe() { try { $subscriber = Subscriber::create(['email' => Binput::get('email')]); } catch (ValidationException $e) { return Redirect::route('subscribe.subscribe')->withInput(Binput::all())->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->withErrors($e->getMessageBag()); } event(new CustomerHasSubscribedEvent($subscriber)); return Redirect::route('status-page')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed'))); }
/** * Update an existing group. * * @param \CachetHQ\Cachet\Models\ComponentGroup $group * * @return \Illuminate\Http\JsonResponse */ public function putGroup(ComponentGroup $group) { $groupData = array_filter(Binput::only(['name', 'order'])); try { $group->update($groupData); } catch (Exception $e) { throw new BadRequestHttpException(); } return $this->item($group); }
/** * Updates a user. * * @param \CachetHQ\Cachet\Models\User $user * * @return \Illuminate\View\View */ public function postUpdateUser(User $user) { $userData = array_filter(Binput::only(['username', 'email', 'password', 'level'])); try { $user->update($userData); } catch (ValidationException $e) { return Redirect::route('dashboard.team.edit', ['id' => $user->id])->withInput($userData)->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))->withErrors($e->getMessageBag()); } return Redirect::route('dashboard.team.edit', ['id' => $user->id])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success'))); }
/** * Update an existing group. * * @param \CachetHQ\Cachet\Models\ComponentGroup $group * * @return \Illuminate\Http\JsonResponse */ public function putGroup(ComponentGroup $group) { $groupData = array_filter(Binput::only(['name', 'order'])); try { $group = $this->dispatch(new UpdateComponentGroupCommand($group, Binput::get('name'), Binput::get('order', 0))); } catch (Exception $e) { throw new BadRequestHttpException(); } return $this->item($group); }
/** * Update an existing incident. * * @param \CachetHQ\Cachet\Models\Inicdent $incident * * @return \Illuminate\Http\JsonResponse */ public function putIncident(Incident $incident) { $incidentData = array_filter(Binput::only(['name', 'message', 'status', 'component_id', 'notify', 'visible'])); try { $incident->update($incidentData); } catch (Exception $e) { throw new BadRequestHttpException(); } return $this->item($incident); }
/** * Create a new subscriber. * * @return \Illuminate\Http\JsonResponse */ public function postSubscribers() { $verified = Binput::get('verify', app(Repository::class)->get('setting.skip_subscriber_verification')); try { $subscriber = dispatch(new SubscribeSubscriberCommand(Binput::get('email'), $verified, Binput::get('components'))); } catch (QueryException $e) { throw new BadRequestHttpException(); } return $this->item($subscriber); }
/** * Handle the subscribe user. * * @return \Illuminate\View\View */ public function postSubscribe() { $subscriber = Subscriber::create(['email' => Binput::get('email')]); if (!$subscriber->isValid()) { return Redirect::back()->withInput(Binput::all())->with('title', sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->with('errors', $subscriber->getErrors()); } $successMsg = sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')); event(new CustomerHasSubscribedEvent($subscriber)); return Redirect::route('status-page')->with('success', $successMsg); }
/** * Updates a metric point. * * @param \CachetHQ\Cachet\Models\Metric $metric * @param \CachetHQ\Cachet\Models\MetircPoint $metricPoint * * @return \Illuminate\Http\JsonResponse */ public function putMetricPoint(Metric $metric, MetricPoint $metricPoint) { $metricPointData = Binput::all(); $metricPointData['metric_id'] = $metric->id; if ($timestamp = array_pull($metricPointData, 'timestamp')) { $pointTimestamp = Carbon::createFromFormat('U', $timestamp); $metricPointData['created_at'] = $pointTimestamp->format('Y-m-d H:i:s'); } $metricPoint->update($metricPointData); return $this->item($metricPoint); }
/** * Creates a new subscriber. * * @return \Illuminate\Http\RedirectResponse */ public function createSubscriberAction() { $email = Binput::get('email'); $subscriber = Subscriber::create(['email' => $email]); if (!$subscriber->isValid()) { return Redirect::back()->withInput(Binput::all())->with('title', sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))->with('errors', $subscriber->getErrors()); } $successMsg = sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')); event(new CustomerHasSubscribedEvent($subscriber)); return Redirect::back()->with('success', $successMsg); }
/** * Updates a components ordering. * * @return array */ public function postUpdateComponentOrder() { $componentData = Binput::all(); unset($componentData['component'][0]); // Remove random 0 index. foreach ($componentData['component'] as $componentId => $order) { $component = Component::find($componentId); $component->update(['order' => $order]); } return $componentData; }
/** * Creates a new subscriber. * * @return \Illuminate\Http\RedirectResponse */ public function createSubscriberAction() { $email = Binput::get('email'); try { $subscriber = Subscriber::create(['email' => $email]); } catch (ValidationException $e) { return Redirect::route('dashboard.subscribers.add')->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))->withErrors($e->getMessageBag()); } event(new CustomerHasSubscribedEvent($subscriber)); return Redirect::route('dashboard.subscribers.add')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success'))); }
/** * Handle the subscribe user. * * @return \Illuminate\View\View */ public function postSubscribe() { $email = Binput::get('email'); try { dispatch(new SubscribeSubscriberCommand($email)); } catch (AlreadySubscribedException $e) { return Redirect::route('subscribe.subscribe')->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->withErrors(trans('cachet.subscriber.email.already-subscribed', ['email' => $email])); } catch (ValidationException $e) { return Redirect::route('subscribe.subscribe')->withInput(Binput::all())->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->withErrors($e->getMessageBag()); } return Redirect::route('status-page')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed'))); }