mirror of
https://github.com/cydrobolt/polr.git
synced 2024-09-19 15:11:40 +02:00
Fix API bugs and implement directive for setup tooltips
This commit is contained in:
parent
202f5d244d
commit
e17aeff740
@ -12,6 +12,10 @@ class ApiAnalyticsController extends ApiController {
|
||||
$user = $request->user;
|
||||
$response_type = $request->input('response_type') ?: 'json';
|
||||
|
||||
if ($user->anonymous) {
|
||||
throw new ApiException('AUTH_ERROR', 'Anonymous access of this API is not permitted.', 401, $response_type);
|
||||
}
|
||||
|
||||
if ($response_type != 'json') {
|
||||
throw new ApiException('JSON_ONLY', 'Only JSON-encoded data is available for this endpoint.', 401, $response_type);
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ class ApiMiddleware {
|
||||
throw new ApiException('AUTH_ERROR', 'Authentication token required.', 401, $response_type);
|
||||
}
|
||||
$user = (object) [
|
||||
'username' => $username
|
||||
'username' => $username,
|
||||
'anonymous' => true
|
||||
];
|
||||
}
|
||||
else {
|
||||
@ -33,9 +34,10 @@ class ApiMiddleware {
|
||||
->first();
|
||||
|
||||
if (!$user) {
|
||||
throw new ApiException('AUTH_ERROR', 'Authentication token required.', 401, $response_type);
|
||||
throw new ApiException('AUTH_ERROR', 'Authentication token invalid.', 401, $response_type);
|
||||
}
|
||||
$username = $user->username;
|
||||
$user->anonymous = false;
|
||||
}
|
||||
|
||||
$api_limit_reached = ApiHelper::checkUserApiQuota($username);
|
||||
|
@ -38,6 +38,7 @@ input.api-quota {
|
||||
width: 9em;
|
||||
font-size: .85em;
|
||||
height: .85em;
|
||||
padding-left: 0.8em;
|
||||
}
|
||||
|
||||
.wrap-text {
|
||||
|
@ -1,3 +1,13 @@
|
||||
polr.directive('setupTooltip', function() {
|
||||
return {
|
||||
scope: {
|
||||
content: '@',
|
||||
},
|
||||
replace: true,
|
||||
template: '<button data-content="{{ content }}" type="button" class="btn btn-xs btn-default setup-qmark" data-toggle="popover">?</button>'
|
||||
}
|
||||
})
|
||||
|
||||
polr.controller('SetupCtrl', function($scope) {
|
||||
$scope.init = function () {
|
||||
$('[data-toggle="popover"]').popover({
|
||||
|
Loading…
Reference in New Issue
Block a user