mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-14 07:48:37 +02:00
Add Default group option in Settings
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user