My Account: Added self-delete flow
This commit is contained in:
parent
cf72e48d2a
commit
f9422dff18
6 changed files with 89 additions and 13 deletions
|
@ -191,4 +191,31 @@ class UserAccountController extends Controller
|
|||
|
||||
return redirect('/my-account/auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the user self-delete page.
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$this->setPageTitle(trans('preferences.delete_my_account'));
|
||||
|
||||
return view('users.account.delete', [
|
||||
'category' => 'profile',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the current user from the system.
|
||||
*/
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$this->preventAccessInDemoMode();
|
||||
|
||||
$requestNewOwnerId = intval($request->get('new_owner_id')) ?: null;
|
||||
$newOwnerId = userCan('users-manage') ? $requestNewOwnerId : null;
|
||||
|
||||
$this->userRepo->destroy(user(), $newOwnerId);
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,4 +43,9 @@ return [
|
|||
'profile_avatar_desc' => 'Select an image which will be used to represent yourself to others in the system. Ideally this image should be square and about 256px in width and height.',
|
||||
'profile_admin_options' => 'Administrator Options',
|
||||
'profile_admin_options_desc' => 'Additional administrator-level options, like those to manage role assignments, can be found for your user account in the "Settings > Users" area of the application.',
|
||||
|
||||
'delete_account' => 'Delete Account',
|
||||
'delete_my_account' => 'Delete My Account',
|
||||
'delete_my_account_desc' => 'This will fully delete your user account from the system. You will not be able to recover this account or revert this action. Content you\'ve created, such as created pages and uploaded images, will remain.',
|
||||
'delete_my_account_warning' => 'Are you sure you want to delete your account?',
|
||||
];
|
||||
|
|
43
resources/views/users/account/delete.blade.php
Normal file
43
resources/views/users/account/delete.blade.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
@extends('users.account.layout')
|
||||
|
||||
@section('main')
|
||||
|
||||
<div class="card content-wrap auto-height">
|
||||
<form action="{{ url("/my-account") }}" method="POST">
|
||||
{{ csrf_field() }}
|
||||
{{ method_field('delete') }}
|
||||
|
||||
|
||||
<h1 class="list-heading">{{ trans('preferences.delete_my_account') }}</h1>
|
||||
|
||||
<p>{{ trans('preferences.delete_my_account_desc') }}</p>
|
||||
|
||||
@if(userCan('users-manage'))
|
||||
<hr class="my-l">
|
||||
|
||||
<div class="grid half gap-xl v-center">
|
||||
<div>
|
||||
<label class="setting-list-label">{{ trans('settings.users_migrate_ownership') }}</label>
|
||||
<p class="small">{{ trans('settings.users_migrate_ownership_desc') }}</p>
|
||||
</div>
|
||||
<div>
|
||||
@include('form.user-select', ['name' => 'new_owner_id', 'user' => null])
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<hr class="my-l">
|
||||
|
||||
<div class="grid half">
|
||||
<p class="text-neg"><strong>{{ trans('preferences.delete_my_account_warning') }}</strong></p>
|
||||
<div class="text-right">
|
||||
<a href="{{ url("/my-account/profile") }}"
|
||||
class="button outline">{{ trans('common.cancel') }}</a>
|
||||
<button type="submit" class="button">{{ trans('common.confirm') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@stop
|
|
@ -68,6 +68,7 @@
|
|||
</div>
|
||||
|
||||
<div class="form-group text-right">
|
||||
<a href="{{ url('/my-account/delete') }}" class="button outline">{{ trans('preferences.delete_account') }}</a>
|
||||
<button class="button">{{ trans('common.save') }}</button>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -6,33 +6,31 @@
|
|||
@include('settings.parts.navbar', ['selected' => 'users'])
|
||||
|
||||
<form action="{{ url("/settings/users/{$user->id}") }}" method="POST">
|
||||
{!! csrf_field() !!}
|
||||
{{ csrf_field() }}
|
||||
{{ method_field('delete') }}
|
||||
|
||||
<div class="card content-wrap auto-height">
|
||||
<h1 class="list-heading">{{ trans('settings.users_delete') }}</h1>
|
||||
|
||||
<p>{{ trans('settings.users_delete_warning', ['userName' => $user->name]) }}</p>
|
||||
|
||||
@if(userCan('users-manage'))
|
||||
<hr class="my-l">
|
||||
<hr class="my-l">
|
||||
|
||||
<div class="grid half gap-xl v-center">
|
||||
<div>
|
||||
<label class="setting-list-label">{{ trans('settings.users_migrate_ownership') }}</label>
|
||||
<p class="small">{{ trans('settings.users_migrate_ownership_desc') }}</p>
|
||||
</div>
|
||||
<div>
|
||||
@include('form.user-select', ['name' => 'new_owner_id', 'user' => null])
|
||||
</div>
|
||||
<div class="grid half gap-xl v-center">
|
||||
<div>
|
||||
<label class="setting-list-label">{{ trans('settings.users_migrate_ownership') }}</label>
|
||||
<p class="small">{{ trans('settings.users_migrate_ownership_desc') }}</p>
|
||||
</div>
|
||||
@endif
|
||||
<div>
|
||||
@include('form.user-select', ['name' => 'new_owner_id', 'user' => null])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="my-l">
|
||||
|
||||
<div class="grid half">
|
||||
<p class="text-neg"><strong>{{ trans('settings.users_delete_confirm') }}</strong></p>
|
||||
<div class="text-right">
|
||||
<input type="hidden" name="_method" value="DELETE">
|
||||
<a href="{{ url("/settings/users/{$user->id}") }}" class="button outline">{{ trans('common.cancel') }}</a>
|
||||
<button type="submit" class="button">{{ trans('common.confirm') }}</button>
|
||||
</div>
|
||||
|
|
|
@ -242,6 +242,8 @@ Route::middleware('auth')->group(function () {
|
|||
Route::put('/my-account/notifications', [UserControllers\UserAccountController::class, 'updateNotifications']);
|
||||
Route::get('/my-account/auth', [UserControllers\UserAccountController::class, 'showAuth']);
|
||||
Route::put('/my-account/auth/password', [UserControllers\UserAccountController::class, 'updatePassword']);
|
||||
Route::get('/my-account/delete', [UserControllers\UserAccountController::class, 'delete']);
|
||||
Route::delete('/my-account', [UserControllers\UserAccountController::class, 'destroy']);
|
||||
Route::patch('/preferences/change-view/{type}', [UserControllers\UserPreferencesController::class, 'changeView']);
|
||||
Route::patch('/preferences/change-sort/{type}', [UserControllers\UserPreferencesController::class, 'changeSort']);
|
||||
Route::patch('/preferences/change-expansion/{type}', [UserControllers\UserPreferencesController::class, 'changeExpansion']);
|
||||
|
|
Loading…
Reference in a new issue