mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-19 19:28:08 +02:00
Bind QrCodeService to the Service Container
This commit is contained in:
parent
9bf165895f
commit
14609dec95
@ -4,7 +4,6 @@ namespace App\Api\v1\Controllers;
|
|||||||
|
|
||||||
use App\Models\TwoFAccount;
|
use App\Models\TwoFAccount;
|
||||||
use App\Services\QrCodeService;
|
use App\Services\QrCodeService;
|
||||||
use App\Services\TwoFAccountService;
|
|
||||||
use App\Api\v1\Requests\QrCodeDecodeRequest;
|
use App\Api\v1\Requests\QrCodeDecodeRequest;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
@ -16,23 +15,16 @@ class QrCodeController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected $qrcodeService;
|
protected $qrcodeService;
|
||||||
|
|
||||||
/**
|
|
||||||
* The TwoFAccount Service instance.
|
|
||||||
*/
|
|
||||||
protected $twofaccountService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new controller instance.
|
* Create a new controller instance.
|
||||||
*
|
*
|
||||||
* @param \App\Services\QrCodeService $qrcodeService
|
* @param \App\Services\QrCodeService $qrcodeService
|
||||||
* @param \App\Services\TwoFAccountService $twofaccountService
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(QrCodeService $qrcodeService, TwoFAccountService $twofaccountService)
|
public function __construct(QrCodeService $qrcodeService)
|
||||||
{
|
{
|
||||||
$this->qrcodeService = $qrcodeService;
|
$this->qrcodeService = $qrcodeService;
|
||||||
$this->twofaccountService = $twofaccountService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Services\LogoService;
|
use App\Services\LogoService;
|
||||||
|
use App\Services\QrCodeService;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||||
|
|
||||||
@ -18,6 +19,10 @@ class TwoFAuthServiceProvider extends ServiceProvider implements DeferrableProvi
|
|||||||
$this->app->singleton(LogoService::class, function ($app) {
|
$this->app->singleton(LogoService::class, function ($app) {
|
||||||
return new LogoService();
|
return new LogoService();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->app->singleton(QrCodeService::class, function ($app) {
|
||||||
|
return new QrCodeService();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,6 +43,9 @@ class TwoFAuthServiceProvider extends ServiceProvider implements DeferrableProvi
|
|||||||
*/
|
*/
|
||||||
public function provides()
|
public function provides()
|
||||||
{
|
{
|
||||||
return [LogoService::class];
|
return [
|
||||||
|
LogoService::class,
|
||||||
|
QrCodeService::class,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,25 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Models\TwoFAccount;
|
|
||||||
use Zxing\QrReader;
|
use Zxing\QrReader;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use chillerlan\QRCode\{QRCode, QROptions};
|
use chillerlan\QRCode\{QRCode, QROptions};
|
||||||
|
|
||||||
class QrCodeService
|
class QrCodeService
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//private $token;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
//$this->token = $otpType === TOTP::create($secret) : HOTP::create($secret);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode a string into a QR code image
|
* Encode a string into a QR code image
|
||||||
*
|
*
|
||||||
|
@ -4,7 +4,7 @@ namespace Tests\Feature\Services;
|
|||||||
|
|
||||||
use Tests\FeatureTestCase;
|
use Tests\FeatureTestCase;
|
||||||
use Tests\Classes\LocalFile;
|
use Tests\Classes\LocalFile;
|
||||||
use Illuminate\Support\Facades\DB;
|
use App\Services\QrCodeService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +29,7 @@ class QrCodeServiceTest extends FeatureTestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->qrcodeService = $this->app->make('App\Services\QrCodeService');
|
$this->qrcodeService = $this->app->make(QrCodeService::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user