mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-03-26 22:16:06 +01:00
Add Default group option in Settings
This commit is contained in:
parent
0d2449adc7
commit
a8e5535d6b
@ -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 @@ public function store(Request $request)
|
||||
'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);
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
'showAccountsIcons' => true,
|
||||
'kickUserAfter' => '15',
|
||||
'activeGroup' => 0,
|
||||
'defaultGroup' => 0,
|
||||
'useEncryption' => false,
|
||||
],
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
<form-select :options="layouts" :form="form" fieldName="displayMode" :label="$t('settings.forms.display_mode.label')" :help="$t('settings.forms.display_mode.help')" />
|
||||
<!-- show icon -->
|
||||
<form-checkbox :form="form" fieldName="showAccountsIcons" :label="$t('settings.forms.show_accounts_icons.label')" :help="$t('settings.forms.show_accounts_icons.help')" />
|
||||
<!-- default group -->
|
||||
<form-select :options="groups" :form="form" fieldName="defaultGroup" :label="$t('settings.forms.default_group.label')" :help="$t('settings.forms.default_group.help')" />
|
||||
|
||||
<h4 class="title is-4">{{ $t('settings.security') }}</h4>
|
||||
<!-- auto lock -->
|
||||
@ -42,6 +44,7 @@
|
||||
displayMode: this.$root.appSettings.displayMode,
|
||||
kickUserAfter: this.$root.appSettings.kickUserAfter,
|
||||
useEncryption: this.$root.appSettings.useEncryption,
|
||||
defaultGroup: this.$root.appSettings.defaultGroup,
|
||||
}),
|
||||
langs: [
|
||||
{ text: this.$t('languages.en'), value: 'en' },
|
||||
@ -61,10 +64,18 @@
|
||||
{ text: this.$t('settings.forms.30_minutes'), value: '30' },
|
||||
{ text: this.$t('settings.forms.1_hour'), value: '60' },
|
||||
{ text: this.$t('settings.forms.1_day'), value: '1440' },
|
||||
],
|
||||
groups: [
|
||||
{ text: this.$t('groups.no_group'), value: 0 },
|
||||
{ text: this.$t('groups.active_group'), value: -1 },
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.fetchGroups()
|
||||
},
|
||||
|
||||
methods : {
|
||||
handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
@ -86,6 +97,21 @@
|
||||
this.$notify({ type: 'is-danger', text: error.response.data.message })
|
||||
});
|
||||
},
|
||||
|
||||
fetchGroups() {
|
||||
|
||||
this.axios.get('api/groups').then(response => {
|
||||
response.data.forEach((data) => {
|
||||
if( data.id >0 ) {
|
||||
this.groups.push({
|
||||
text: data.name,
|
||||
value: data.id
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
@ -16,6 +16,7 @@
|
||||
'groups' => 'Groups',
|
||||
'select_accounts_to_show' => 'Select accounts to show',
|
||||
'manage_groups' => 'Manage groups',
|
||||
'active_group' => 'Active group',
|
||||
'manage_groups_legend' => 'You can create groups to organize your accounts the way you want. All accounts remain visible in the pseudo group named \'All\', regardless of the group they belong to.',
|
||||
'deleting_group_does_not_delete_accounts' => 'Deleting a group does not delete accounts',
|
||||
'no_group' => 'No group',
|
||||
|
@ -60,6 +60,10 @@
|
||||
'label' => 'Protect sensible data',
|
||||
'help' => 'Sensitive data, the 2FA secrets and emails, are stored encrypted in database. Be sure to backup the APP_KEY value of your .env file (or the whole file) as it serves as key encryption. There is no way to decypher encrypted data without this key.',
|
||||
],
|
||||
'default_group' => [
|
||||
'label' => 'Default group',
|
||||
'help' => 'The group to which the newly created accounts are associated',
|
||||
],
|
||||
'never' => 'Never',
|
||||
'on_token_copy' => 'On security code copy',
|
||||
'1_minutes' => 'After 1 minute',
|
||||
|
Loading…
Reference in New Issue
Block a user