Skip to content

Commit

Permalink
Show button in settings for deleting user
Browse files Browse the repository at this point in the history
  • Loading branch information
range-of-motion committed Aug 20, 2020
1 parent fe0a1a1 commit 8b37ab5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Image;
use Storage;
use Hash;
use Illuminate\Support\Facades\Auth as FacadesAuth;
use Mail;

class SettingsController extends Controller
Expand Down Expand Up @@ -94,6 +95,17 @@ public function getAccount()
return view('settings.account');
}

public function postAccountDelete()
{
$user = Auth::user();

Auth::logout();

$user->delete();

return redirect()->route('login');
}

public function getSpaces()
{
return view('settings.spaces.index', [
Expand Down
15 changes: 15 additions & 0 deletions resources/views/settings/account.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,18 @@
</div>
</div>
@endsection

@section('settings_body_formless')
<div class="mt-3">
<h3 class="mb-1">Delete</h3>
<div class="box">
<div class="box__section">
<div class="mb-2">Deleting your user is irreversible.</div>
<form method="POST" action="{{ route('settings.account.delete') }}">
{{ csrf_field() }}
<button class="button">I know, do it anyway</button>
</form>
</div>
</div>
</div>
@endsection
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
Route::post('/settings', [SettingsController::class, 'postIndex']);
Route::get('/settings/profile', [SettingsController::class, 'getProfile'])->name('profile');
Route::get('/settings/account', [SettingsController::class, 'getAccount'])->name('account');
Route::post('/settings/account/delete', [SettingsController::class, 'postAccountDelete'])->name('account.delete');
Route::get('/settings/preferences', [SettingsController::class, 'getPreferences'])->name('preferences');
Route::get('/settings/billing', [SettingsController::class, 'getBilling'])->name('billing')->middleware('stripe');
Route::post('/settings/billing/upgrade', [SettingsController::class, 'postUpgrade'])->name('billing.upgrade')->middleware('stripe');
Expand Down

0 comments on commit 8b37ab5

Please sign in to comment.