Add restrictions for demo accounts.

This commit is contained in:
James Cole 2016-12-25 13:09:29 +01:00
parent ede327f3d3
commit bce4e7e2bf
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 26 additions and 0 deletions

View File

@ -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')));

View File

@ -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',