diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 3399c84644..30b0553d0b 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -51,6 +51,12 @@ class ProfileController extends Controller */ public function changePassword() { + if (auth()->user()->hasRole('demo')) { + Session::flash('info', strval(trans('firefly.cannot_change_demo'))); + + return redirect(route('profile.index')); + } + $title = auth()->user()->email; $subTitle = strval(trans('firefly.change_your_password')); $subTitleIcon = 'fa-key'; @@ -63,6 +69,12 @@ class ProfileController extends Controller */ public function deleteAccount() { + if (auth()->user()->hasRole('demo')) { + Session::flash('info', strval(trans('firefly.cannot_delete_demo'))); + + return redirect(route('profile.index')); + } + $title = auth()->user()->email; $subTitle = strval(trans('firefly.delete_account')); $subTitleIcon = 'fa-trash'; @@ -90,6 +102,12 @@ class ProfileController extends Controller */ public function postChangePassword(ProfileFormRequest $request, UserRepositoryInterface $repository) { + if (auth()->user()->hasRole('demo')) { + Session::flash('info', strval(trans('firefly.cannot_change_demo'))); + + return redirect(route('profile.index')); + } + // old, new1, new2 if (!Hash::check($request->get('current_password'), auth()->user()->password)) { Session::flash('error', strval(trans('firefly.invalid_current_password'))); @@ -118,6 +136,12 @@ class ProfileController extends Controller */ public function postDeleteAccount(UserRepositoryInterface $repository, DeleteAccountFormRequest $request) { + if (auth()->user()->hasRole('demo')) { + Session::flash('info', strval(trans('firefly.cannot_delete_demo'))); + + return redirect(route('profile.index')); + } + // old, new1, new2 if (!Hash::check($request->get('password'), auth()->user()->password)) { Session::flash('error', strval(trans('firefly.invalid_password'))); diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index af44a37ef1..d53f683541 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -96,6 +96,8 @@ return [ 'spent_in_specific_budget' => 'Spent in budget ":budget"', 'sum_of_expenses_in_budget' => 'Spent total in budget ":budget"', 'left_in_budget_limit' => 'Left to spend according to budgeting', + 'cannot_change_demo' => 'You cannot change the password of the demonstration account.', + 'cannot_delete_demo' => 'You cannot remove the demonstration account.', // repeat frequencies: 'repeat_freq_yearly' => 'yearly',