mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-25 06:51:08 +00:00
Built a routine that will allow you to completely delete an account.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use FireflyIII\Http\Requests;
|
use FireflyIII\Http\Requests;
|
||||||
|
use FireflyIII\Http\Requests\DeleteAccountFormRequest;
|
||||||
use FireflyIII\Http\Requests\ProfileFormRequest;
|
use FireflyIII\Http\Requests\ProfileFormRequest;
|
||||||
use Hash;
|
use Hash;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
@@ -34,6 +35,36 @@ class ProfileController extends Controller
|
|||||||
return view('profile.index')->with('title', 'Profile')->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user');
|
return view('profile.index')->with('title', 'Profile')->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function deleteAccount()
|
||||||
|
{
|
||||||
|
return view('profile.delete-account')->with('title', Auth::user()->email)->with('subTitle', 'Delete account')->with(
|
||||||
|
'mainTitleIcon', 'fa-user'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function postDeleteAccount(DeleteAccountFormRequest $request) {
|
||||||
|
// old, new1, new2
|
||||||
|
if (!Hash::check($request->get('password'), Auth::user()->password)) {
|
||||||
|
Session::flash('error', 'Invalid password!');
|
||||||
|
|
||||||
|
return Redirect::route('delete-account');
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE!
|
||||||
|
Auth::user()->delete();
|
||||||
|
Session::flush();
|
||||||
|
return Redirect::route('index');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
|
32
app/Http/Requests/DeleteAccountFormRequest.php
Normal file
32
app/Http/Requests/DeleteAccountFormRequest.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Requests;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class DeleteAccountFormRequest
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Http\Requests
|
||||||
|
*/
|
||||||
|
class DeleteAccountFormRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
// Only allow logged in users
|
||||||
|
return Auth::check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'password' => 'required',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@@ -282,6 +282,8 @@ Route::group(
|
|||||||
*/
|
*/
|
||||||
Route::get('/profile', ['uses' => 'ProfileController@index', 'as' => 'profile']);
|
Route::get('/profile', ['uses' => 'ProfileController@index', 'as' => 'profile']);
|
||||||
Route::get('/profile/change-password', ['uses' => 'ProfileController@changePassword', 'as' => 'change-password']);
|
Route::get('/profile/change-password', ['uses' => 'ProfileController@changePassword', 'as' => 'change-password']);
|
||||||
|
Route::get('/profile/delete-account', ['uses' => 'ProfileController@deleteAccount', 'as' => 'delete-account']);
|
||||||
|
Route::post('/profile/delete-account', ['uses' => 'ProfileController@postDeleteAccount', 'as' => 'delete-account-post']);
|
||||||
Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword', 'as' => 'change-password-post']);
|
Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword', 'as' => 'change-password-post']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -41,6 +41,9 @@ class CreateAccountMetaTable extends Migration
|
|||||||
|
|
||||||
$table->unique(['account_id', 'name']);
|
$table->unique(['account_id', 'name']);
|
||||||
|
|
||||||
|
// link to account!
|
||||||
|
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
49
resources/views/profile/delete-account.blade.php
Normal file
49
resources/views/profile/delete-account.blade.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
@extends('layouts.default')
|
||||||
|
@section('content')
|
||||||
|
{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName()) !!}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 col-md-12 col-sm-12">
|
||||||
|
<div class="panel panel-red">
|
||||||
|
<div class="panel-heading">
|
||||||
|
Delete your account
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
|
<p class="text-danger">
|
||||||
|
Deleting your account will also delete any accounts, transactions, <em>anything</em>
|
||||||
|
you might have saved into Firefly III. It'll be GONE.
|
||||||
|
</p>
|
||||||
|
<p class="text-danger">
|
||||||
|
Enter your password to continue.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
@if($errors->count() > 0)
|
||||||
|
<ul>
|
||||||
|
@foreach($errors->all() as $err)
|
||||||
|
<li class="text-info">{{$err}}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{!! Form::open(['class' => 'form-horizontal','id' => 'change-password']) !!}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password" class="col-sm-4 control-label">Password</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="password" class="form-control" id="password" placeholder="Password" name="password">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-4 col-sm-10">
|
||||||
|
<button type="submit" onclick="confirm('Are you sure? You cannot undo this.')" class="btn btn-danger">DELETE your account</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{!! Form::close() !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@stop
|
||||||
|
@section('scripts')
|
||||||
|
@stop
|
@@ -8,7 +8,10 @@
|
|||||||
Options
|
Options
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<a href="{{route('change-password')}}">Change your password</a>
|
<ul>
|
||||||
|
<li><a href="{{route('change-password')}}">Change your password</a></li>
|
||||||
|
<li><a class="text-danger" href="{{route('delete-account')}}">Delete account</a></li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user