mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Cleanup cleanup [skip ci]
This commit is contained in:
parent
42799b9273
commit
b7433683d8
@ -56,16 +56,34 @@ class Cleanup
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
}
|
||||
$run = env('RUNCLEANUP') == 'true' ? true : false;
|
||||
$count = 0;
|
||||
$count = -1;
|
||||
|
||||
if ($run) {
|
||||
bcscale(0);
|
||||
|
||||
if (env('RUNCLEANUP') == 'true') {
|
||||
$count = 0;
|
||||
$count = bcadd($count, $this->encryptAccountAndBills());
|
||||
$count = bcadd($count, $this->encryptBudgetsAndCategories());
|
||||
$count = bcadd($count, $this->encryptPiggiesAndJournals());
|
||||
$count = bcadd($count, $this->encryptRemindersAndPreferences());
|
||||
|
||||
}
|
||||
if ($count == 0) {
|
||||
Session::flash('warning', 'Please open the .env file and change RUNCLEANUP=true to RUNCLEANUP=false');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
protected function encryptAccountAndBills()
|
||||
{
|
||||
$count = 0;
|
||||
// encrypt account name
|
||||
$set = Account::where('encrypted', 0)->take(5)->get();
|
||||
/** @var Account $entry */
|
||||
@ -98,6 +116,18 @@ class Cleanup
|
||||
}
|
||||
unset($set, $entry, $match);
|
||||
|
||||
|
||||
return $count;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
protected function encryptBudgetsAndCategories()
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
// encrypt budget name
|
||||
$set = Budget::where('encrypted', 0)->take(5)->get();
|
||||
/** @var Budget $entry */
|
||||
@ -120,6 +150,17 @@ class Cleanup
|
||||
}
|
||||
unset($set, $entry, $name);
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
protected function encryptPiggiesAndJournals()
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
|
||||
// encrypt piggy bank name
|
||||
$set = PiggyBank::where('encrypted', 0)->take(5)->get();
|
||||
/** @var PiggyBank $entry */
|
||||
@ -142,6 +183,16 @@ class Cleanup
|
||||
}
|
||||
unset($set, $entry, $description);
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
protected function encryptRemindersAndPreferences()
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
// encrypt reminder metadata
|
||||
$set = Reminder::where('encrypted', 0)->take(5)->get();
|
||||
/** @var Reminder $entry */
|
||||
@ -175,12 +226,7 @@ class Cleanup
|
||||
}
|
||||
unset($set, $entry, $data);
|
||||
|
||||
}
|
||||
if ($count == 0 && $run) {
|
||||
Session::flash('warning', 'Please open the .env file and change RUNCLEANUP=true to RUNCLEANUP=false');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
return $count;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user