|
@@ -17,6 +17,7 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
* @property int|null $period
|
|
|
* @property int|null $counter
|
|
|
* @property string $legacy_uri
|
|
|
+ * @method string getURI()
|
|
|
*/
|
|
|
class TwoFAccountExportResource extends JsonResource
|
|
|
{
|
|
@@ -28,19 +29,23 @@ class TwoFAccountExportResource extends JsonResource
|
|
|
*/
|
|
|
public function toArray($request)
|
|
|
{
|
|
|
- return [
|
|
|
- 'otp_type' => $this->otp_type,
|
|
|
- 'account' => $this->account,
|
|
|
- 'service' => $this->service,
|
|
|
- 'icon' => $this->icon,
|
|
|
- 'icon_mime' => $this->icon && IconStore::exists($this->icon) ? IconStore::mimeType($this->icon) : null,
|
|
|
- 'icon_file' => $this->icon && IconStore::exists($this->icon) ? base64_encode(IconStore::get($this->icon)) : null,
|
|
|
- 'secret' => $this->secret,
|
|
|
- 'digits' => (int) $this->digits,
|
|
|
- 'algorithm' => $this->algorithm,
|
|
|
- 'period' => is_null($this->period) ? null : (int) $this->period,
|
|
|
- 'counter' => is_null($this->counter) ? null : (int) $this->counter,
|
|
|
- 'legacy_uri' => $this->legacy_uri,
|
|
|
- ];
|
|
|
+ return $request->has('otpauth') && $request->boolean('otpauth')
|
|
|
+ ? [
|
|
|
+ 'uri' => urldecode($this->getURI()),
|
|
|
+ ]
|
|
|
+ : [
|
|
|
+ 'otp_type' => $this->otp_type,
|
|
|
+ 'account' => $this->account,
|
|
|
+ 'service' => $this->service,
|
|
|
+ 'icon' => $this->icon,
|
|
|
+ 'icon_mime' => $this->icon && IconStore::exists($this->icon) ? IconStore::mimeType($this->icon) : null,
|
|
|
+ 'icon_file' => $this->icon && IconStore::exists($this->icon) ? base64_encode(IconStore::get($this->icon)) : null,
|
|
|
+ 'secret' => $this->secret,
|
|
|
+ 'digits' => (int) $this->digits,
|
|
|
+ 'algorithm' => $this->algorithm,
|
|
|
+ 'period' => is_null($this->period) ? null : (int) $this->period,
|
|
|
+ 'counter' => is_null($this->counter) ? null : (int) $this->counter,
|
|
|
+ 'legacy_uri' => $this->legacy_uri,
|
|
|
+ ];
|
|
|
}
|
|
|
}
|