mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-04-11 11:08:44 +02:00
Set icon filename generation as a helper function
This commit is contained in:
parent
e79ae0a3ed
commit
1af32ecbf4
20
app/Helpers/Helpers.php
Normal file
20
app/Helpers/Helpers.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class Helpers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generate a unique filename
|
||||||
|
*
|
||||||
|
* @param string $ids twofaccount ids to delete
|
||||||
|
*
|
||||||
|
* @return string The filename
|
||||||
|
*/
|
||||||
|
public static function getUniqueFilename(string $extension): string
|
||||||
|
{
|
||||||
|
return Str::random(40).'.'.$extension;
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,7 @@
|
|||||||
use ParagonIE\ConstantTime\Base32;
|
use ParagonIE\ConstantTime\Base32;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use App\Helpers\Helpers;
|
||||||
|
|
||||||
class TwoFAccount extends Model implements Sortable
|
class TwoFAccount extends Model implements Sortable
|
||||||
{
|
{
|
||||||
@ -537,7 +538,7 @@ private function storeImageAsIcon(string $url)
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$path_parts = pathinfo($url);
|
$path_parts = pathinfo($url);
|
||||||
$newFilename = Str::random(40).'.'.$path_parts['extension'];
|
$newFilename = Helpers::getUniqueFilename($path_parts['extension']); //Str::random(40).'.'.$path_parts['extension'];
|
||||||
$imageFile = self::IMAGELINK_STORAGE_PATH . $newFilename;
|
$imageFile = self::IMAGELINK_STORAGE_PATH . $newFilename;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -232,7 +232,7 @@
|
|||||||
'QrCode' => App\Facades\QrCode::class,
|
'QrCode' => App\Facades\QrCode::class,
|
||||||
'Groups' => App\Facades\Groups::class,
|
'Groups' => App\Facades\Groups::class,
|
||||||
'TwoFAccounts' => App\Facades\TwoFAccounts::class,
|
'TwoFAccounts' => App\Facades\TwoFAccounts::class,
|
||||||
|
'Helpers' => App\Helpers\Helpers::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user