mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-05-30 23:06:29 +02:00
Add automatic icon retrieval for Steam account
This commit is contained in:
parent
e03ec30040
commit
b01718f2e8
@ -370,7 +370,7 @@ class TwoFAccount extends Model implements Sortable
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function fillWithOtpParameters(array $parameters, bool $isSteamTotp = false)
|
public function fillWithOtpParameters(array $parameters)
|
||||||
{
|
{
|
||||||
$this->otp_type = Arr::get($parameters, 'otp_type');
|
$this->otp_type = Arr::get($parameters, 'otp_type');
|
||||||
$this->account = Arr::get($parameters, 'account');
|
$this->account = Arr::get($parameters, 'account');
|
||||||
@ -384,7 +384,7 @@ class TwoFAccount extends Model implements Sortable
|
|||||||
|
|
||||||
$this->initGenerator();
|
$this->initGenerator();
|
||||||
|
|
||||||
if ($isSteamTotp) {
|
if ($this->otp_type === self::STEAM_TOTP || strtolower($this->service) === 'steam') {
|
||||||
$this->enforceAsSteam();
|
$this->enforceAsSteam();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,13 +431,12 @@ class TwoFAccount extends Model implements Sortable
|
|||||||
$this->counter = $this->generator->hasParameter('counter') ? $this->generator->getParameter('counter') : null;
|
$this->counter = $this->generator->hasParameter('counter') ? $this->generator->getParameter('counter') : null;
|
||||||
$this->legacy_uri = $uri;
|
$this->legacy_uri = $uri;
|
||||||
|
|
||||||
if ($isSteamTotp) {
|
if ($isSteamTotp || strtolower($this->service) === 'steam') {
|
||||||
$this->enforceAsSteam();
|
$this->enforceAsSteam();
|
||||||
}
|
}
|
||||||
|
else if ($this->generator->hasParameter('image')) {
|
||||||
if ( $this->generator->hasParameter('image') ) {
|
$this->icon = $this->storeImageAsIcon($this->generator->getParameter('image'));
|
||||||
$this->icon = $this->storeTokenImageAsIcon();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Log::info(sprintf('TwoFAccount filled with an URI'));
|
Log::info(sprintf('TwoFAccount filled with an URI'));
|
||||||
|
|
||||||
@ -454,6 +453,7 @@ class TwoFAccount extends Model implements Sortable
|
|||||||
$this->digits = 5;
|
$this->digits = 5;
|
||||||
$this->algorithm = self::SHA1;
|
$this->algorithm = self::SHA1;
|
||||||
$this->period = 30;
|
$this->period = 30;
|
||||||
|
$this->icon = $this->storeImageAsIcon('https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Steam_icon_logo.svg/langfr-320px-Steam_icon_logo.svg.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -523,14 +523,14 @@ class TwoFAccount extends Model implements Sortable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the image resource pointed by the generator image parameter and store it as an icon
|
* Gets the image resource pointed by the image url and store it as an icon
|
||||||
*
|
*
|
||||||
* @return string|null The filename of the stored icon or null if the operation fails
|
* @return string|null The filename of the stored icon or null if the operation fails
|
||||||
*/
|
*/
|
||||||
private function storeTokenImageAsIcon()
|
private function storeImageAsIcon(string $url)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$remoteImageURL = $this->generator->getParameter('image');
|
$remoteImageURL = $url;
|
||||||
$path_parts = pathinfo($remoteImageURL);
|
$path_parts = pathinfo($remoteImageURL);
|
||||||
$newFilename = Str::random(40) . '.' . $path_parts['extension'];
|
$newFilename = Str::random(40) . '.' . $path_parts['extension'];
|
||||||
$imageFile = self::IMAGELINK_STORAGE_PATH . $newFilename;
|
$imageFile = self::IMAGELINK_STORAGE_PATH . $newFilename;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user