Small items

parent 4264e2c5
......@@ -2,3 +2,11 @@
Username: user<br/>
Password: password
</div>
<div>
<form class="well form-inline">
<h3>Login</h3>
<input ng-model="login.username" type="text" val="username" placeholder="Username">
<input ng-model="login.password" type="password" val="password" placeholder="Password">
<button type="submit" class="btn" ng-click="login()">Log in</button>
</form>
</div>
......@@ -39,7 +39,7 @@ archivingPortalClient.config(['$routeProvider', function ($routeProvider) {
archivingPortalClient.run(['$rootScope', '$injector', function($rootScope, $injector) {
$injector.get("$http").defaults.transformRequest = function(data, headersGetter) {
headersGetter()['Authorization'] = "Bearer ACCESS_TOKEN";
headersGetter()['Authorization'] = "Bearer ACCESS_TOKEN";//+$rootScope.ACCESS_TOKEN;
if (data) {
return angular.toJson(data);
......
'use strict';
var MainController = function() {
var MainController = function($scope, $log, $http, RequestToken, TokenService, $rootScope) {
//$rootScope.ACCESS_TOKEN = "27a05bcf-b731-493d-8cc3-987e52d99080";
//$log.info($rootScope.ACCESS_TOKEN);
//$log.info($http.get('http://localhost:8080/nation/list'));
//$log.info($http.get('http://localhost:8080/user'));
//var token = RequestToken.save();
//
//$log.info(token);
//var token = TokenService();
//$scope.login = {};
//
//$scope.login = function() {
// $log.info("Hello");
// var loginString = 'password='+$scope.login.password+'&username='+$scope.login.username+'&grant_type=password&scope=write&client_secret=123456&client_id=html5-archivingportal';
//
//
//
// var key = window.btoa('html5-archivingportal:123456');
//$log.info(key);
//
// $http.post(
// 'http://localhost:8080/oauth/token'
// , "grant_type=password"
// , {headers: {'Authorization': 'Basic ' + key}}
// )
//}
};
......@@ -3,14 +3,30 @@
var ProjectController = function($scope, $log, $http) {
$scope.project = {};
$scope.dataSet = {};
$scope.dataSetFile = {};
//$scope.dataSet = {};
//$scope.dataSetFile = {};
//$scope.create = function() {
// $http.post($scope.portalApiUrl+'project/create', angular.toJson($scope.project))
// .success(function(result) {
// $log.info(result)
// })
// .error(function (error) {
// $log.error("Unable to post -> " + angular.toJson($scope.project));
// $log.error(error);
// });
//}
$scope.create = function() {
$log.info(angular.toJson($scope.project));
$http.post($scope.portalApiUrl+'project/create', angular.toJson($scope.project))
.success(function() {
.success(function(val) {
$log.info(val);
}).error(function () {
$log.error("Unable to post -> " + angular.toJson($scope.project));
});
}
};
};
......@@ -12,3 +12,56 @@ schemaServices.factory('Nations', ['$resource',
}]);
}
]);
// password=password&username=admin&grant_type=password&scope=write&client_secret=123456&client_id=html5-archivingportal
/**
* This method doesnt send the user name when logging in.
*/
schemaServices.factory('RequestToken', ['$resource',
function($resource) {
return $resource(apiUrl+"oauth/token", {}, [{
save: {
headers: {'Authorization': 'Basic aHRtbDUtYXJjaGl2aW5ncG9ydGFsOjEyMzQ1Ng=='},
method: 'POST',
params:{
password:'password',
username:'admin',
grant_type:'password',
scope:'write',
client_secret:'123456',
client_id:'html5-archivingportal'
}
}
}]);
}]);
schemaServices.factory('TokenService', function ($resource, $http, $log) {
//var consumerKey = encodeURIComponent('<your consumer key>')
//var consumerSecret = encodeURIComponent('<your consumer secret>')
//var credentials = bota(consumerKey + ':' + consumerSecret)
// Twitters OAuth service endpoint
var oauthEndpoint = $http.post(
'http://localhost:8080/oauth2/token',
'password=password&username=admin&grant_type=password&scope=write&client_secret=123456&client_id=html5-archivingportal',
{user: {'Authorization': 'Basic aHRtbDUtYXJjaGl2aW5ncG9ydGFsOjEyMzQ1Ng==', 'Content-Type': 'application/json;charset=UTF-8'}}
);
$log.info(oauthEndpoint);
oauthEndpoint.success(function (response) {
//$log.info(response);
// a successful response will return
// the "bearer" token which is registered
// to the $httpProvider
//$httpProvider.defaults.headers.common['Authorization'] = "Bearer " + response.access_token
$log.info(response);
}).error(function (response) {
// error handling to some meaningful extent
//$log.error(response);
});
return oauthEndpoint;
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment