Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- angular.module("Diplomka").factory('oauth', ['$rootScope', function oauth($scope, $http) {
- 'use strict';
- return {
- login: function (username, password) {
- var token = "";
- var config = {
- headers: {
- "Content-Type": "application/x-www-form-urlencoded"
- }
- }
- var data = {
- username: username,
- password: password,
- grant_type: "password"
- }
- //var data = "grant_type=password&username=" + username + "&password=" + password;
- $http.post("/Token", data, config)
- .then(function (response) {
- //currentUser.setProfile(username, response.data.access_token)
- token = response.access_token;
- //return username;
- });
- }
- };
- }]);
- 'use strict';
- app.controller('LoginController', ['$scope', 'oauth', '$location', LoginController]);
- function LoginController($scope, oauth, $location) {
- $scope.username = "";
- $scope.password = "";
- $scope.signIn = function () {
- oauth.login($scope.username, $scope.password);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement