Created
January 22, 2015 14:00
-
-
Save simonmorley/a162d0ee798c66ac3e80 to your computer and use it in GitHub Desktop.
Medium, creating a splash page, aruba service part 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var app = angular.module('ctLoginsApp.aruba.services', ['ngResource']); | |
| app.factory('Aruba', ['$http', '$q', | |
| function($http, $q){ | |
| var login = function(params) { | |
| $http.defaults.headers.common = {}; | |
| $http.defaults.headers.post = {}; | |
| var request = $http({ | |
| method: 'POST', | |
| url: 'https://' + params.loginUri + '/cgi-bin/login', | |
| headers: { | |
| 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
| }, | |
| data: $.param({ | |
| cmd: 'authenticate', | |
| mac: params.clientMac, | |
| user: params.username, | |
| password: params.password | |
| }) | |
| }); | |
| return( request.then( handleSuccess, handleError ) ); | |
| }; | |
| var handleError = function(response, a) { | |
| return( true ); | |
| } | |
| var handleSuccess = function(response) { | |
| return( response.data ); | |
| }; | |
| return { | |
| login: login | |
| }; | |
| }]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment