Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.factory("getToken", ["$http", function () {
- return function (username, password) {
- return $http.post('token', {
- username: username,
- password: password,
- grant_type: "password"
- })
- .success(function (data) {
- return data.access_token;
- })
- .error(function (err) {
- return err;
- });
- }
- }]);
- app.controller('loginForm', ['$scope', 'getToken', function ($scope, getToken) {
- $scope.sendToServer = function (user) {
- getToken(user.email, user.password)
- .success(function (data) {
- $scope.token = data;
- }).error(function (err) {
- $scope.tokenError = err;
- });
- };
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement