Login token refresh : GWM

This commit is contained in:
Gowtham M 2025-08-30 14:18:55 +05:30
parent b0a6b5c859
commit 11c06278c4
2 changed files with 45 additions and 0 deletions

View File

@ -48,6 +48,8 @@ $routes->post('forgotPassword/changePassword', 'UserController::forgotChangePass
//api's with token
$routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) {
$routes->get('user/refreshUserToken', 'AuthController::refreshUserToken');
//Organization
$routes->get('organizations', 'OrganizationController::index');

View File

@ -324,5 +324,48 @@ class AuthController extends ResourceController
}
//re-Fetch token
public function refreshUserToken()
{
$user_id = $this->request->getGet();
$user = $this->userModel->where('user_id', $user_id)->where('is_active',1)->first();
// print_r($user);die;
if (!$user) {
return $this->failUnauthorized('Invalid User');
}
//get service for the organization
$orgService = $this->organizationModel->find($user['org_id']);
$user['service'] = json_decode($orgService['services_ids'],true);
foreach ($user['service'] as $key => $value)
{
$serviceData = $this->serviceModel->find($value['service_id']);
$user['service'][$key]['name'] = $serviceData['name'];
$user['service'][$key]['icon'] = $serviceData['icon'];
$user['service'][$key]['order'] = $serviceData['order'];
}
//get role
$user['role'] = $this->userModel->getRole($user['role_id']);
//find user has the all access
$user['plan_action'] = getUserPlanCreationRestrictionStatus($user);
// Generate JWT Token
$token = generateJWT($user);
return $this->respond([
'status' => 200,
'message' => 'Login successful',
'token' => $token
]);
}
}