Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F125433667
D5887.1779470540.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D5887.1779470540.diff
View Options
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;
@@ -230,7 +231,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)
{
@@ -263,11 +264,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
Details
Attached
Mime Type
text/plain
Expires
Fri, May 22, 5:22 PM (22 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18930014
Default Alt Text
D5887.1779470540.diff (2 KB)
Attached To
Mode
D5887: Optional OTP token generation on logon
Attached
Detach File
Event Timeline