forked from Archives/Athou_commafeed
added authentication via api key for some limited api methods (fix #64)
This commit is contained in:
@@ -184,10 +184,11 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
|
||||
});
|
||||
}]);
|
||||
|
||||
module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedService', 'CategoryService', '$dialog',
|
||||
function($scope, $state, $stateParams, FeedService, CategoryService, $dialog) {
|
||||
module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedService', 'CategoryService', 'ProfileService', '$dialog',
|
||||
function($scope, $state, $stateParams, FeedService, CategoryService, ProfileService, $dialog) {
|
||||
|
||||
$scope.CategoryService = CategoryService;
|
||||
$scope.user = ProfileService.get();
|
||||
|
||||
$scope.sub = FeedService.get({
|
||||
id : $stateParams._id
|
||||
@@ -250,9 +251,10 @@ module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedS
|
||||
};
|
||||
}]);
|
||||
|
||||
module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedService', 'CategoryService', '$dialog',
|
||||
function($scope, $state, $stateParams, FeedService, CategoryService, $dialog) {
|
||||
module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedService', 'CategoryService', 'ProfileService', '$dialog',
|
||||
function($scope, $state, $stateParams, FeedService, CategoryService, ProfileService, $dialog) {
|
||||
$scope.CategoryService = CategoryService;
|
||||
$scope.user = ProfileService.get();
|
||||
|
||||
$scope.isMeta = function() {
|
||||
return parseInt($stateParams._id, 10) != $stateParams._id;
|
||||
@@ -264,7 +266,7 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
|
||||
return elem.id != $scope.category.id;
|
||||
};
|
||||
|
||||
CategoryService.get(function() {
|
||||
CategoryService.init(function() {
|
||||
if ($scope.isMeta()) {
|
||||
$scope.category = {
|
||||
id : $stateParams._id,
|
||||
@@ -785,7 +787,8 @@ function($scope, $location, ProfileService, AnalyticsService) {
|
||||
}
|
||||
var o = {
|
||||
email : $scope.user.email,
|
||||
password : $scope.user.password
|
||||
password : $scope.user.password,
|
||||
newApiKey : $scope.newApiKey
|
||||
};
|
||||
|
||||
ProfileService.save(o, function() {
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
<div class="control-group">
|
||||
<label class="control-label">Feed URL</label>
|
||||
<div class="controls horizontal-align">
|
||||
<a href="{{'rest/category/entriesAsFeed?id=' + category.id}}" target="_blank">{{'rest/category/entriesAsFeed?id=' + category.id}}</a>
|
||||
<a ng-show="user.apiKey" href="{{'rest/category/entriesAsFeed?id=' + category.id + '&apiKey=' + user.apiKey}}" target="_blank">link</a>
|
||||
<span ng-show="!user.apiKey">Generate an API key in your profile first.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
<div class="control-group">
|
||||
<label class="control-label">Feed URL</label>
|
||||
<div class="controls horizontal-align">
|
||||
<a href="{{'rest/feed/entriesAsFeed?id=' + sub.id}}" target="_blank">{{'rest/feed/entriesAsFeed?id=' + sub.id}}</a>
|
||||
<a ng-show="user.apiKey" href="{{'rest/feed/entriesAsFeed?id=' + sub.id + '&apiKey=' + user.apiKey}}" target="_blank">link</a>
|
||||
<span ng-show="!user.apiKey">Generate an API key in your profile first.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -31,6 +31,21 @@
|
||||
<span class="help-inline" ng-show="profileForm.password_c.$error.validator">Passwords do not match</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="password">API key</label>
|
||||
<div class="controls horizontal-align">
|
||||
<span ng-show="user.apiKey">{{user.apiKey}}</span>
|
||||
<span ng-show="!user.apiKey">Not generated yet</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="password">Generate new API key</label>
|
||||
<div class="controls">
|
||||
<input type="checkbox" name="newApiKey" id="newApiKey" ng-model="newApiKey">
|
||||
<span class="help-block">Changing password will generate a new API key</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
|
||||
Reference in New Issue
Block a user