Updated Google Scholar Integration,Updated Admin and HOD Dashboard, Added Google Auth: Login Controller and Routes

This commit is contained in:
tanmaychinchore
2025-11-18 22:24:53 +05:30
parent 9ee3d3eda4
commit 34394e6abf
9 changed files with 1347 additions and 49 deletions

View File

@@ -201,25 +201,39 @@ class PublicationsController extends Controller
if (!$user || !$user->scholar_url) {
return response()->json([
'success' => false,
'message' => 'No Google Scholar URL found for the logged-in user.'
'error' => 'No Google Scholar URL found for the logged-in user.'
], 400);
}
$scholarService = new \App\Services\ScholarService();
$publications = $scholarService->fetchPublications($user->scholar_url);
$result = $scholarService->fetchPublications($user->scholar_url);
// If the service returned an error payload, forward it to UI
if (is_array($result) && array_key_exists('error', $result)) {
// Log more details if available
if (isset($result['body'])) {
\Log::error('ScholarService error body', ['body' => $result['body']]);
} elseif (isset($result['raw'])) {
\Log::warning('ScholarService returned empty articles', ['raw' => $result['raw']]);
}
return response()->json([
'error' => $result['error']
], 200);
}
// Expecting successful shape ['data' => [...]]
$publications = $result['data'] ?? [];
if (empty($publications)) {
return response()->json([
'success' => false,
'message' => 'No publications found from the provided Scholar profile.'
]);
'error' => 'No publications found from the provided Scholar profile.'
], 200);
}
return response()->json([
'success' => true,
'count' => count($publications),
'data' => $publications,
'count' => count($publications),
]);
} catch (\Throwable $e) {