Add a user option to disable Official icons fetching

This commit is contained in:
Bubka 2022-07-21 19:07:53 +02:00
parent b0d263091d
commit 5bab7d4912
6 changed files with 37 additions and 26 deletions

View File

@ -588,7 +588,7 @@ private function getDefaultIcon()
{
$logoService = App::make(LogoService::class);
return $logoService->getIcon($this->service);
return SettingService::get('getOfficialIcons') ? $logoService->getIcon($this->service) : null;
}

View File

@ -60,6 +60,7 @@
'useDirectCapture' => false,
'useWebauthnAsDefault' => false,
'useWebauthnOnly' => false,
'getOfficialIcons' => true,
],
];

View File

@ -13,6 +13,9 @@
<form-toggle v-on:displayMode="saveSetting('displayMode', $event)" :choices="layouts" :form="form" fieldName="displayMode" :label="$t('settings.forms.display_mode.label')" :help="$t('settings.forms.display_mode.help')" />
<!-- show icon -->
<form-checkbox v-on:showAccountsIcons="saveSetting('showAccountsIcons', $event)" :form="form" fieldName="showAccountsIcons" :label="$t('settings.forms.show_accounts_icons.label')" :help="$t('settings.forms.show_accounts_icons.help')" />
<!-- Official icons -->
<form-checkbox v-on:getOfficialIcons="saveSetting('getOfficialIcons', $event)" :form="form" fieldName="getOfficialIcons" :label="$t('settings.forms.get_official_icons.label')" :help="$t('settings.forms.get_official_icons.help')" />
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('groups.groups') }}</h4>
<!-- default group -->
@ -87,6 +90,7 @@
useDirectCapture: null,
defaultCaptureMode: '',
rememberActiveGroup: true,
getOfficialIcons: null,
}),
layouts: [
{ text: this.$t('settings.forms.grid'), value: 'grid', icon: 'th' },

View File

@ -63,7 +63,7 @@
<label class="label">{{ $t('twofaccounts.icon') }}</label>
<div class="field is-grouped">
<!-- i'm lucky button -->
<div class="control">
<div class="control" v-if="$root.appSettings.getOfficialIcons">
<v-button @click="fetchLogo" :color="'is-dark'" :nativeType="'button'" :isDisabled="form.service.length < 1">
<span class="icon is-small">
<font-awesome-icon :icon="['fas', 'globe']" />
@ -367,18 +367,19 @@
},
fetchLogo() {
this.axios.post('/api/v1/icons/default', {service: this.form.service}, {returnError: true}).then(response => {
if (response.status === 201) {
// clean possible already uploaded temp icon
this.deleteIcon()
this.tempIcon = response.data.filename;
}
else this.$notify({type: 'is-warning', text: this.$t('errors.no_logo_found_for_x', {service: this.form.service}) })
})
.catch(error => {
this.$notify({type: 'is-warning', text: this.$t('errors.no_logo_found_for_x', {service: this.form.service}) })
});
if ($root.appSettings.getOfficialIcons) {
this.axios.post('/api/v1/icons/default', {service: this.form.service}, {returnError: true}).then(response => {
if (response.status === 201) {
// clean possible already uploaded temp icon
this.deleteIcon()
this.tempIcon = response.data.filename;
}
else this.$notify({type: 'is-warning', text: this.$t('errors.no_logo_found_for_x', {service: this.form.service}) })
})
.catch(error => {
this.$notify({type: 'is-warning', text: this.$t('errors.no_logo_found_for_x', {service: this.form.service}) })
});
}
},
deleteIcon(event) {

View File

@ -272,18 +272,19 @@
},
fetchLogo() {
this.axios.post('/api/v1/icons/default', {service: this.form.service}, {returnError: true}).then(response => {
if (response.status === 201) {
// clean possible already uploaded temp icon
this.deleteIcon()
this.tempIcon = response.data.filename;
}
else this.$notify({type: 'is-warning', text: this.$t('errors.no_logo_found_for_x', {service: this.form.service}) })
})
.catch(error => {
this.$notify({type: 'is-warning', text: this.$t('errors.no_logo_found_for_x', {service: this.form.service}) })
});
if ($root.appSettings.getOfficialIcons) {
this.axios.post('/api/v1/icons/default', {service: this.form.service}, {returnError: true}).then(response => {
if (response.status === 201) {
// clean possible already uploaded temp icon
this.deleteIcon()
this.tempIcon = response.data.filename;
}
else this.$notify({type: 'is-warning', text: this.$t('errors.no_logo_found_for_x', {service: this.form.service}) })
})
.catch(error => {
this.$notify({type: 'is-warning', text: this.$t('errors.no_logo_found_for_x', {service: this.form.service}) })
});
}
},
deleteIcon(event) {

View File

@ -70,6 +70,10 @@
'label' => 'Show icons',
'help' => 'Show icons accounts in the main view'
],
'get_official_icons' => [
'label' => 'Get official icons',
'help' => '(Try to) Get the official icon of the 2FA issuer when adding an account'
],
'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.'