Page MenuHomePhorge

D5887.1779458565.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D5887.1779458565.diff

diff --git a/src/app/Http/Controllers/API/AuthController.php b/src/app/Http/Controllers/API/AuthController.php
--- a/src/app/Http/Controllers/API/AuthController.php
+++ b/src/app/Http/Controllers/API/AuthController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\API;
use App\Auth\OAuth;
+use App\Auth\Utils as AuthUtils;
use App\AuthAttempt;
use App\Http\Controllers\Controller;
use App\Http\Resources\AuthErrorResource;
@@ -219,7 +220,7 @@
*
* @param Response $tokenResponse the response containing the token
* @param ?User $user The user being authenticated
- * @param ?bool $mode Response mode: 'fast' - return minimum set of user data
+ * @param ?string $mode Response mode: 'fast' - return minimum set of user data, 'otp' - include OTP token
*/
protected static function respondWithToken($tokenResponse, $user = null, $mode = null)
{
@@ -252,11 +253,15 @@
$response = new AuthResource($data);
if ($user) {
- if ($mode == 'fast') {
+ if (str_contains($mode, 'fast')) {
$response->user_id = $user->id;
} else {
$response->withUserInfo(new UserInfoResource($user));
}
+
+ if (str_contains($mode, 'otp')) {
+ $response->otp = $ttl = AuthUtils::tokenCreate((string) $user->id, 24 * 60 * 60);
+ }
}
return $response;
diff --git a/src/app/Http/Resources/AuthResource.php b/src/app/Http/Resources/AuthResource.php
--- a/src/app/Http/Resources/AuthResource.php
+++ b/src/app/Http/Resources/AuthResource.php
@@ -11,6 +11,7 @@
{
public string $status = 'success';
public ?string $message = null;
+ public ?string $otp = null;
public ?int $user_id = null;
public ?array $checkout = null;
public ?array $credentials = null;
@@ -47,6 +48,8 @@
'status' => $this->status,
// @var string Response message
'message' => $this->when(isset($this->message), $this->message),
+ // @var string OTP token
+ 'otp' => $this->when(isset($this->otp), $this->otp),
// @var array Payment checkout information (on signup)
'checkout' => $this->when(isset($this->checkout), $this->checkout),
// @var array{'email': string, 'password': string} New user credentials (on device signup)

File Metadata

Mime Type
text/plain
Expires
Fri, May 22, 2:02 PM (19 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18929866
Default Alt Text
D5887.1779458565.diff (2 KB)

Event Timeline