mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-24 16:09:14 +01:00
Make the logo fetching optional
This commit is contained in:
parent
8e397fb5ca
commit
38d3744d39
@ -168,7 +168,7 @@ public function reorder(TwoFAccountReorderRequest $request)
|
|||||||
public function preview(TwoFAccountUriRequest $request)
|
public function preview(TwoFAccountUriRequest $request)
|
||||||
{
|
{
|
||||||
$twofaccount = new TwoFAccount;
|
$twofaccount = new TwoFAccount;
|
||||||
$twofaccount->fillWithURI($request->uri, $request->custom_otp === TwoFAccount::STEAM_TOTP);
|
$twofaccount->fillWithURI($request->uri, $request->custom_otp === TwoFAccount::STEAM_TOTP, true);
|
||||||
|
|
||||||
return new TwoFAccountStoreResource($twofaccount);
|
return new TwoFAccountStoreResource($twofaccount);
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ public function otp(Request $request, $id = null)
|
|||||||
else {
|
else {
|
||||||
$validatedData = $request->validate((new TwoFAccountUriRequest)->rules());
|
$validatedData = $request->validate((new TwoFAccountUriRequest)->rules());
|
||||||
$twofaccount = new TwoFAccount;
|
$twofaccount = new TwoFAccount;
|
||||||
$twofaccount->fillWithURI($validatedData['uri'], Arr::get($validatedData, 'custom_otp') === TwoFAccount::STEAM_TOTP);
|
$twofaccount->fillWithURI($validatedData['uri'], Arr::get($validatedData, 'custom_otp') === TwoFAccount::STEAM_TOTP, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ public function otp(Request $request, $id = null)
|
|||||||
else {
|
else {
|
||||||
$validatedData = $request->validate((new TwoFAccountStoreRequest)->rules());
|
$validatedData = $request->validate((new TwoFAccountStoreRequest)->rules());
|
||||||
$twofaccount = new TwoFAccount();
|
$twofaccount = new TwoFAccount();
|
||||||
$twofaccount->fillWithOtpParameters($validatedData);
|
$twofaccount->fillWithOtpParameters($validatedData, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json($twofaccount->getOTP(), 200);
|
return response()->json($twofaccount->getOTP(), 200);
|
||||||
|
@ -373,7 +373,7 @@ public function getOTP()
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function fillWithOtpParameters(array $parameters)
|
public function fillWithOtpParameters(array $parameters, bool $skipIconFetching = false)
|
||||||
{
|
{
|
||||||
$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');
|
||||||
@ -391,6 +391,13 @@ public function fillWithOtpParameters(array $parameters)
|
|||||||
$this->enforceAsSteam();
|
$this->enforceAsSteam();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->icon && $skipIconFetching) {
|
||||||
|
$this->icon = $this->getDefaultIcon();
|
||||||
|
}
|
||||||
|
if (!$this->icon && SettingService::get('getOfficialIcons') && !$skipIconFetching) {
|
||||||
|
$this->icon = $this->getDefaultIcon();
|
||||||
|
}
|
||||||
|
|
||||||
Log::info(sprintf('TwoFAccount filled with OTP parameters'));
|
Log::info(sprintf('TwoFAccount filled with OTP parameters'));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -402,7 +409,7 @@ public function fillWithOtpParameters(array $parameters)
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function fillWithURI(string $uri, bool $isSteamTotp = false)
|
public function fillWithURI(string $uri, bool $isSteamTotp = false, bool $skipIconFetching = false)
|
||||||
{
|
{
|
||||||
// First we instanciate the OTP generator
|
// First we instanciate the OTP generator
|
||||||
try {
|
try {
|
||||||
@ -440,7 +447,7 @@ public function fillWithURI(string $uri, bool $isSteamTotp = false)
|
|||||||
if ($this->generator->hasParameter('image')) {
|
if ($this->generator->hasParameter('image')) {
|
||||||
$this->icon = $this->storeImageAsIcon($this->generator->getParameter('image'));
|
$this->icon = $this->storeImageAsIcon($this->generator->getParameter('image'));
|
||||||
}
|
}
|
||||||
if (!$this->icon) {
|
if (!$this->icon && SettingService::get('getOfficialIcons') && !$skipIconFetching) {
|
||||||
$this->icon = $this->getDefaultIcon();
|
$this->icon = $this->getDefaultIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user