mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-20 11:47:53 +02:00
Add the Preferred icon collection user preference
This commit is contained in:
parent
8b745731e2
commit
9e3794a956
@ -5,6 +5,7 @@ namespace App\Services;
|
||||
use App\Facades\IconStore;
|
||||
use App\Facades\LogoLib;
|
||||
use App\Helpers\Helpers;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@ -18,7 +19,7 @@ class IconService
|
||||
*/
|
||||
public function buildFromOfficialLogo(?string $service) : ?string
|
||||
{
|
||||
return LogoLib::driver('tfa')->getIcon($service);
|
||||
return LogoLib::driver(Auth::user()->preferences['iconCollection'])->getIcon($service);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@ $preferences = [
|
||||
'useBasicQrcodeReader' => envUnlessEmpty('USERPREF_DEFAULT__USE_BASIC_QRCODE_READER', false),
|
||||
'displayMode' => envUnlessEmpty('USERPREF_DEFAULT__DISPLAY_MODE', 'list'),
|
||||
'showAccountsIcons' => envUnlessEmpty('USERPREF_DEFAULT__SHOW_ACCOUNTS_ICONS', true),
|
||||
'iconCollection' => envUnlessEmpty('USERPREF_DEFAULT__ICON_COLLECTION', 'selfh'),
|
||||
'kickUserAfter' => envUnlessEmpty('USERPREF_DEFAULT__KICK_USER_AFTER', 15),
|
||||
'activeGroup' => 0,
|
||||
'rememberActiveGroup' => envUnlessEmpty('USERPREF_DEFAULT__REMEMBER_ACTIVE_GROUP', true),
|
||||
|
@ -56,9 +56,10 @@
|
||||
:aria-invalid="fieldError != undefined"
|
||||
:aria-errormessage="fieldError != undefined ? valErrorId : undefined"
|
||||
>
|
||||
<option v-for="option in options" :value="option.value">{{ $t(option.text) }}</option>
|
||||
<option v-for="option in options" :key="option.value" :value="option.value">{{ $t(option.text) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<slot></slot>
|
||||
</div>
|
||||
<FieldError v-if="fieldError != undefined" :error="fieldError" :field="fieldName" />
|
||||
<p :id="legendId" class="help" v-html="$t(help)" v-if="help"></p>
|
||||
|
@ -23,6 +23,11 @@
|
||||
{ text: 'settings.forms.dark', value: 'dark', icon: 'moon' },
|
||||
{ text: 'settings.forms.automatic', value: 'system', icon: 'desktop' },
|
||||
]
|
||||
const iconCollections = [
|
||||
{ text: 'selfh.st', value: 'selfh', url: 'https://selfh.st/icons/' },
|
||||
{ text: 'dashboardicons.com', value: 'dashboardicons', url: 'https://dashboardicons.com/' },
|
||||
{ text: '2fa.directory', value: 'tfa', url: 'https://2fa.directory/' },
|
||||
]
|
||||
const passwordFormats = [
|
||||
{ text: '12 34 56', value: 2, legend: 'settings.forms.pair', title: 'settings.forms.pair_legend' },
|
||||
{ text: '123 456', value: 3, legend: 'settings.forms.trio', title: 'settings.forms.trio_legend' },
|
||||
@ -74,6 +79,14 @@
|
||||
return locales
|
||||
})
|
||||
|
||||
const iconCollectionUrl = computed(() => {
|
||||
return iconCollections.find(({ value }) => value === user.preferences.iconCollection)?.url
|
||||
})
|
||||
|
||||
const iconCollectionDomain = computed(() => {
|
||||
return iconCollections.find(({ value }) => value === user.preferences.iconCollection)?.text
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
groups.items.forEach((group) => {
|
||||
if( group.id > 0 ) {
|
||||
@ -145,6 +158,12 @@
|
||||
<FormCheckbox v-model="user.preferences.showAccountsIcons" @update:model-value="val => savePreference('showAccountsIcons', val)" fieldName="showAccountsIcons" :isLocked="appSettings.lockedPreferences.includes('showAccountsIcons')" label="settings.forms.show_accounts_icons.label" help="settings.forms.show_accounts_icons.help" />
|
||||
<!-- Official icons -->
|
||||
<FormCheckbox v-model="user.preferences.getOfficialIcons" @update:model-value="val => savePreference('getOfficialIcons', val)" fieldName="getOfficialIcons" :isLocked="appSettings.lockedPreferences.includes('getOfficialIcons')" label="settings.forms.get_official_icons.label" help="settings.forms.get_official_icons.help" />
|
||||
<!-- icon collections -->
|
||||
<FormSelect v-model="user.preferences.iconCollection" @update:model-value="val => savePreference('iconCollection', val)" :options="iconCollections" fieldName="iconCollection" :isLocked="appSettings.lockedPreferences.includes('iconCollection')" :isDisabled="!user.preferences.getOfficialIcons" label="settings.forms.icon_collection.label" help="settings.forms.icon_collection.help" :isIndented="true">
|
||||
<a class="button is-ghost" :href="iconCollectionUrl" target="_blank" :title="$t('commons.visit_x', { website: iconCollectionDomain})">
|
||||
<FontAwesomeIcon :icon="['fas', 'external-link-alt']" />
|
||||
</a>
|
||||
</FormSelect>
|
||||
<!-- password format -->
|
||||
<FormCheckbox v-model="user.preferences.formatPassword" @update:model-value="val => savePreference('formatPassword', val)" fieldName="formatPassword" :isLocked="appSettings.lockedPreferences.includes('formatPassword')" label="settings.forms.password_format.label" help="settings.forms.password_format.help" />
|
||||
<FormToggle v-model="user.preferences.formatPasswordBy" @update:model-value="val => savePreference('formatPasswordBy', val)" :choices="passwordFormats" fieldName="formatPasswordBy" :isLocked="appSettings.lockedPreferences.includes('formatPasswordBy')" :isDisabled="!user.preferences.formatPassword" />
|
||||
|
@ -92,4 +92,5 @@ return [
|
||||
'x_month' => ':x mos.',
|
||||
'one_year' => '1 yr.',
|
||||
'copy_next_password' => 'Copy next password to clipboard',
|
||||
'visit_x' => 'Visit :website'
|
||||
];
|
||||
|
@ -125,6 +125,10 @@ return [
|
||||
'label' => 'Get official icons',
|
||||
'help' => '(Try to) Get the official icon of the 2FA issuer when adding an account'
|
||||
],
|
||||
'icon_collection' => [
|
||||
'label' => 'Preferred icons source',
|
||||
'help' => 'The icons collection to be queried when an official icon is required. Changing this setting does not refresh icons that have already been fetched.'
|
||||
],
|
||||
'auto_lock' => [
|
||||
'label' => 'Auto lock',
|
||||
'help' => 'Log out the user automatically in case of inactivity. Has no effect when authentication is handled by a proxy and no custom logout url is specified.'
|
||||
|
Loading…
x
Reference in New Issue
Block a user