ImportController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Api\v1\Controllers;
  3. use App\Api\v1\Requests\TwoFAccountImportRequest;
  4. use App\Api\v1\Resources\TwoFAccountCollection;
  5. use App\Contracts\MigrationService;
  6. use App\Http\Controllers\Controller;
  7. class ImportController extends Controller
  8. {
  9. /**
  10. * @var $migrator The Migration service
  11. */
  12. protected $migrator;
  13. /**
  14. * Constructor
  15. */
  16. public function __construct(MigrationService $migrationService)
  17. {
  18. $this->migrator = $migrationService;
  19. }
  20. /**
  21. * Convert Google Auth data to a TwoFAccounts collection
  22. *
  23. * @param \App\Api\v1\Requests\TwoFAccountImportRequest $request
  24. * @return \App\Api\v1\Resources\TwoFAccountCollection
  25. */
  26. public function googleAuth(TwoFAccountImportRequest $request)
  27. {
  28. $request->merge(['withSecret' => true]);
  29. $twofaccounts = $this->migrator->migrate($request->uri);
  30. return new TwoFAccountCollection($twofaccounts);
  31. }
  32. /**
  33. * Convert Aegis data to a TwoFAccounts collection
  34. *
  35. * @param \App\Api\v1\Requests\TwoFAccountImportRequest $request
  36. * @return \App\Api\v1\Resources\TwoFAccountCollection
  37. */
  38. public function aegis(TwoFAccountImportRequest $request)
  39. {
  40. $request->merge(['withSecret' => true]);
  41. $twofaccounts = $this->migrator->migrate($request->uri);
  42. return new TwoFAccountCollection($twofaccounts);
  43. }
  44. }