/** * Store a newly created resource in storage. * * @param StoreUserRequest $request * * @return \Illuminate\Http\Response */ public function store(StoreUserRequest $request) { $userStored = $this->userRepository->store($request->all()); if (!$userStored) { Flash::error(trans('ahk_messages.unable_to_store_user')); return redirect()->back(); } Flash::success(trans('ahk_messages.user_created')); return redirect()->route('home_path'); }
/** * @param array $data * @param bool $rememberMe * @param bool $login * * @return User|false */ public function attemptToSignIn(array $data, $rememberMe = false, $login = false) { if (!Auth::validate(array_only($data, ['email', 'password']))) { Flash::error(trans('ahk_messages.credentials_mismatch')); return false; } $user = $this->findByEmail($data['email']); if (!$user->verified) { Flash::error(trans('ahk_messages.please_validate_your_email_first')); return false; } Auth::login($user); return $user; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param Guard $guard * * @return mixed */ public function handle(Request $request, Closure $next, Guard $guard = null) { if (Auth::guard($guard)->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } Flash::error(trans('cms.you_need_to_sign_in_first')); return redirect()->guest(route('cms.sessions.create')); } $user = Auth::user(); if (!$user->verified) { Flash::error('Please visit your email to validate your account.'); return redirect()->route('cms.sessions.create'); } if (!$this->userRepository->hasAdministratorRole($user)) { Flash::error(trans('cms.missing_required_role')); return redirect()->route('cms.sessions.create'); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param Guard|null $guard * * @return mixed */ public function handle(Request $request, Closure $next, Guard $guard = null) { if (Auth::guard($guard)->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { Flash::error(trans('ahk_messages.you_need_to_sign_in')); return redirect()->guest(route('auth.sign_in')); } } $user = Auth::user(); if (!$user->verified) { Flash::error(trans('cms.missing_required_role')); return redirect()->route('cms.sessions.create'); } if (!$this->userRepository->hasCompanyRepresentativeRole($user)) { Flash::error(trans('ahk_messages.you_do_not_have_the_necessary_privileges')); return redirect()->route('auth.sign_in'); } return $next($request); }
/** * Remove the specified session from storage. * * @return Response */ public function destroy() { Auth::logout(); Flash::success(trans('ahk_messages.successful_sign_out')); return redirect()->route('home_path'); }
/** * Update the specified resource in storage. * * @param UpdateArticleRequest $request * @param int $id * * @return \Illuminate\Http\Response */ public function update($id, UpdateArticleRequest $request) { $article = $this->articleRepository->getById($id); if ($article === null) { Flash::error('cms.article_does_not_exists'); return redirect()->back(); } $category = $this->categoryRepository->getById($request->get('category_id')); $articleUpdated = $this->articleRepository->updateById($id, $request->only(['title', 'description', 'publish', 'source', 'content', 'img_url']), $category); if (!$articleUpdated) { Flash::error(trans('cms.unable_to_update_article')); return redirect()->back(); } Flash::success(trans('cms.article_updated')); $tagsUpdated = $this->articleRepository->updateTagsById($articleUpdated->id, $request->get('tagIds', [])); if (!$tagsUpdated) { Flash::error(trans('cms.unable_to_update_tags')); } return redirect()->route('cms.articles.edit', $articleUpdated); }
public function response(array $messages) { Flash::error(trans('ahk_messages.validation_error_occurred')); return parent::response($messages); }
/** * @param $slug * @param $recovery_token * @param ResetPasswordRequest $request * * @return \Illuminate\Http\RedirectResponse */ public function postReset($slug, $recovery_token, ResetPasswordRequest $request) { $user = $this->userRepository->findBySlugAndRecoveryToken($slug, $recovery_token); if (!$user) { Flash::error('ahk_messages.validation_error_occurred'); return redirect()->back(); } $user = $this->userRepository->updatePassword($user, $request->get(User::PASSWORD)); if (!$user) { Flash::error(trans('ahk_messages.unknown_error_occurred')); } else { Flash::success(trans('ahk_messages.you_updated_your_accounts_password')); } return redirect()->route('auth.sign_in'); }
/** * Update the specified category in storage. * * @param $id * @param UpdateCategoryRequest $request * * @return \Illuminate\Http\RedirectResponse */ public function update($id, UpdateCategoryRequest $request) { $categorySaved = $this->categoryRepository->updateById($id, $request->only('name')); if (!$categorySaved) { Flash::error(trans('cms.something_went_wrong')); return redirect()->back(); } Flash::success(trans('cms.category_updated')); return redirect()->route('cms.articles.categories.edit', $categorySaved); }
public function confirmEmail(Requests\Ahk\ConfirmEmailRequest $request) { $this->userRepository->confirmEmail($request->only('token')); Flash::success(trans('ahk_messages.successful_sign_up')); return redirect()->route('home_path'); }
/** * Update the specified resource in storage. * * @param UpdateCompanyRequest $request * @param Company $company * * @return \Illuminate\Http\Response */ public function update(UpdateCompanyRequest $request, Company $company) { $user = Auth::user(); if (!$this->userRepository->hasCompany($user, $company)) { Flash::error(trans('ahk_messages.you_do_not_have_the_necessary_privileges')); return back()->withInput(); } $file = $request->file('logo_path'); if (null !== $file) { $this->fileRepository->update($company->logo, [File::CLIENT_ORIGINAL_NAME => $file->getClientOriginalName(), File::TEMPORARY_PATH => $file->getRealPath()]); } if (!($company = $this->companyRepository->update($company, $request->all()))) { Flash::error(trans('ahk_messages.unknown_error_occurred')); return redirect()->back(); } Flash::success(trans('ahk_messages.company_successfully_updated')); return redirect()->route('my.companies.edit', ['slug' => $company->slug]); }
/** * Remove the specified session from storage. * * @return Response */ public function destroy() { Auth::logout(); Flash::success('You have successfully signed out!'); return redirect()->route('cms.sessions.create'); }