Skip to content

Commit

Permalink
feat(token): add token
Browse files Browse the repository at this point in the history
  • Loading branch information
tikrack committed Jan 28, 2025
1 parent 97a72fc commit d287d63
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Jobs\SendOtpJob;
use App\Models\User;
use App\Services\SmsService;
use Request;

class AuthController extends Controller
{
Expand Down Expand Up @@ -55,4 +56,25 @@ public function verify(VerifyRequest $request)

return null;
}

public function token(Request $request)
{
$user = $request->user();

$userData = [
'id' => $user?->id,
'name' => $user?->name,
'family' => $user?->family,
'mobile' => $user?->mobile,
'role' => $user?->getRoleNames()->toArray()
];

if ($user) {
return $this->success([
'user' => $userData,
], 'Otp is correct');
} else {
return $this->fail(null, 'Otp is incorrect', 404);
}
}
}

0 comments on commit d287d63

Please sign in to comment.