mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-20 11:47:53 +02:00
Add ability to force the queried icons collection on the Advanced form
This commit is contained in:
parent
9e3794a956
commit
c693c840b2
@ -11,6 +11,7 @@ use App\Models\TwoFAccount;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class IconController extends Controller
|
||||
{
|
||||
@ -52,7 +53,11 @@ class IconController extends Controller
|
||||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
$icon = LogoLib::driver('tfa')->getIcon($validated['service']);
|
||||
$iconCollection = Arr::has($validated, 'iconCollection') && $validated['iconCollection']
|
||||
? $validated['iconCollection']
|
||||
: $request->user()->preferences['iconCollection'];
|
||||
|
||||
$icon = LogoLib::driver($iconCollection)->getIcon($validated['service']);
|
||||
|
||||
return $icon
|
||||
? response()->json(['filename' => $icon], 201)
|
||||
|
@ -26,6 +26,7 @@ class IconFetchRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'service' => 'string',
|
||||
'iconCollection' => 'nullable|string|in:tfa,selfh,dashboardicons',
|
||||
];
|
||||
}
|
||||
|
||||
|
4
resources/js/services/twofaccountService.js
vendored
4
resources/js/services/twofaccountService.js
vendored
@ -23,8 +23,8 @@ export default {
|
||||
return apiClient.post('/twofaccounts', { uri: uri }, { ...config })
|
||||
},
|
||||
|
||||
getLogo(service, config = {}) {
|
||||
return apiClient.post('/icons/default', { service: service }, { ...config })
|
||||
getLogo(service, iconCollection, config = {}) {
|
||||
return apiClient.post('/icons/default', { service: service, iconCollection: iconCollection }, { ...config })
|
||||
},
|
||||
|
||||
deleteIcon(icon, config = {}) {
|
||||
|
@ -37,6 +37,11 @@
|
||||
const iconForm = reactive(new Form({
|
||||
icon: null
|
||||
}))
|
||||
const iconCollections = [
|
||||
{ text: 'selfh.st', value: 'selfh' },
|
||||
{ text: 'dashboardicons.com', value: 'dashboardicons' },
|
||||
{ text: '2fa.directory', value: 'tfa' },
|
||||
]
|
||||
const otpDisplayProps = ref({
|
||||
otp_type: '',
|
||||
account : '',
|
||||
@ -69,6 +74,7 @@
|
||||
const showAdvancedForm = ref(false)
|
||||
const ShowTwofaccountInModal = ref(false)
|
||||
const fetchingLogo = ref(false)
|
||||
const iconCollection = ref(user.preferences.iconCollection)
|
||||
|
||||
// $refs
|
||||
const iconInput = ref(null)
|
||||
@ -379,7 +385,7 @@
|
||||
if (user.preferences.getOfficialIcons) {
|
||||
fetchingLogo.value = true
|
||||
|
||||
twofaccountService.getLogo(form.service, { returnError: true })
|
||||
twofaccountService.getLogo(form.service, iconCollection.value, { returnError: true })
|
||||
.then(response => {
|
||||
if (response.status === 201) {
|
||||
// clean possible already uploaded temp icon
|
||||
@ -486,16 +492,31 @@
|
||||
<FormField v-model="form.account" fieldName="account" :fieldError="form.errors.get('account')" label="twofaccounts.account" :placeholder="$t('twofaccounts.forms.account.placeholder')" />
|
||||
<!-- icon upload -->
|
||||
<label for="filUploadIcon" class="label">{{ $t('twofaccounts.icon') }}</label>
|
||||
<div class="columns is-mobile mb-0">
|
||||
<div class="column">
|
||||
<!-- try my luck -->
|
||||
<fieldset v-if="user.preferences.getOfficialIcons" :disabled="!form.service">
|
||||
<div class="field is-grouped">
|
||||
<!-- Try my luck button -->
|
||||
<div class="control" v-if="user.preferences.getOfficialIcons">
|
||||
<VueButton @click="fetchLogo" :color="mode == 'dark' ? 'is-dark' : ''" :nativeType="'button'" :is-loading="fetchingLogo" :isDisabled="!form.service" aria-describedby="lgdTryMyLuck">
|
||||
<div class="control">
|
||||
<VueButton @click="fetchLogo" :color="mode == 'dark' ? 'is-dark' : ''" :nativeType="'button'" :is-loading="fetchingLogo" aria-describedby="lgdTryMyLuck">
|
||||
<span class="icon is-small">
|
||||
<FontAwesomeIcon :icon="['fas', 'globe']" />
|
||||
</span>
|
||||
<span>{{ $t('twofaccounts.forms.i_m_lucky') }}</span>
|
||||
</VueButton>
|
||||
</div>
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select name="icon-collection" v-model="iconCollection">
|
||||
<option v-for="collection in iconCollections" :key="collection.text" :value="collection.value">
|
||||
{{ collection.text }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="field is-grouped">
|
||||
<!-- upload icon button -->
|
||||
<div class="control is-flex">
|
||||
<div role="button" tabindex="0" class="file mr-3" :class="mode == 'dark' ? 'is-dark' : 'is-white'" @keyup.enter="iconInputLabel.click()">
|
||||
@ -515,6 +536,10 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-narrow" style="width: 200px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<FieldError v-if="iconForm.errors.hasAny('icon')" :error="iconForm.errors.get('icon')" :field="'icon'" class="help-for-file" />
|
||||
<p id="lgdTryMyLuck" v-if="user.preferences.getOfficialIcons" class="help" v-html="$t('twofaccounts.forms.i_m_lucky_legend')"></p>
|
||||
|
@ -66,7 +66,7 @@ return [
|
||||
],
|
||||
'choose_image' => 'Upload',
|
||||
'i_m_lucky' => 'Try my luck',
|
||||
'i_m_lucky_legend' => 'The "Try my luck" button try to get the official icon of the given service. Enter actual service name without ".xyz" extension and try to avoid typo. (beta feature)',
|
||||
'i_m_lucky_legend' => 'The "Try my luck" button tries to get a standard icon from the selected icon collection. The simpler the service value, the more likely you are to get the correct icon: Do not append any extension (like ".com"), use the exact name of the service, avoid special chars.',
|
||||
'test' => 'Test',
|
||||
'group' => [
|
||||
'label' => 'Group',
|
||||
|
Loading…
x
Reference in New Issue
Block a user