Add Default group option in Settings

This commit is contained in:
Bubka
2020-11-02 22:41:40 +01:00
parent 0d2449adc7
commit a8e5535d6b
5 changed files with 45 additions and 0 deletions

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Group;
use App\TwoFAccount;
use App\Classes\OTP;
use App\Classes\Options;
@ -47,6 +48,18 @@ class TwoFAccountController extends Controller
'icon' => $request->icon
]);
// Possible group association
$groupId = Options::get('defaultGroup') === '-1' ? (int) Options::get('activeGroup') : (int) Options::get('defaultGroup');
// 0 is the pseudo group 'All', only groups with id > 0 are true user groups
if( $groupId > 0 ) {
$group = Group::find($groupId);
if($group) {
$group->twofaccounts()->save($twofaccount);
}
}
return response()->json($twofaccount, 201);
}