Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. 'use strict';
  2. angular.module("Diplomka").factory('oauth', ['$rootScope', function oauth($scope, $http) {
  3. 'use strict';
  4. return {
  5. login: function (username, password) {
  6. var token = "";
  7. var config = {
  8. headers: {
  9. "Content-Type": "application/x-www-form-urlencoded"
  10. }
  11. }
  12.  
  13. var data = {
  14. username: username,
  15. password: password,
  16. grant_type: "password"
  17. }
  18.  
  19. //var data = "grant_type=password&username=" + username + "&password=" + password;
  20.  
  21. $http.post("/Token", data, config)
  22. .then(function (response) {
  23. //currentUser.setProfile(username, response.data.access_token)
  24. token = response.access_token;
  25. //return username;
  26. });
  27. }
  28. };
  29. }]);
  30.  
  31. 'use strict';
  32. app.controller('LoginController', ['$scope', 'oauth', '$location', LoginController]);
  33. function LoginController($scope, oauth, $location) {
  34.  
  35.  
  36. $scope.username = "";
  37. $scope.password = "";
  38.  
  39. $scope.signIn = function () {
  40. oauth.login($scope.username, $scope.password);
  41. }
  42.  
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement