Login token refresh : GWM
This commit is contained in:
parent
b0a6b5c859
commit
11c06278c4
@ -48,6 +48,8 @@ $routes->post('forgotPassword/changePassword', 'UserController::forgotChangePass
|
|||||||
//api's with token
|
//api's with token
|
||||||
$routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) {
|
$routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) {
|
||||||
|
|
||||||
|
$routes->get('user/refreshUserToken', 'AuthController::refreshUserToken');
|
||||||
|
|
||||||
|
|
||||||
//Organization
|
//Organization
|
||||||
$routes->get('organizations', 'OrganizationController::index');
|
$routes->get('organizations', 'OrganizationController::index');
|
||||||
|
|||||||
@ -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
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user