Skip to content

Instantly share code, notes, and snippets.

View simonmorley's full-sized avatar

Simon Morley simonmorley

  • London
View GitHub Profile
@simonmorley
simonmorley / gist:116bf4e3a3b79306ee5f
Created January 20, 2015 22:40
Medium, creating a login page, Coova Service with Logon
'use strict';
var app = angular.module('ctLoginsApp.coova.services', ['ngResource']);
app.factory('Coova', ['$resource',
function($resource){
return $resource( 'http://:uamip::uamport' + '/json/:action?',
{ callback: 'JSON_CALLBACK' },
@simonmorley
simonmorley / gist:3d6c4537b3d8d8e55678
Created January 20, 2015 22:56
Medium, creating a login page, full login.
var doLogin = function(username, password, challenge) {
var createLogin = function() {
return Tony.create({username: username, password: password, challenge: challenge, request_uri: $location.host(), clientMac: $routeParams.mac}).$promise.then(function(res) {
scope.username = res.username;
scope.response = res.challengeResp;
}, function(err) {
// Fail Login
});
},
@simonmorley
simonmorley / gist:bfa0e925b48497902e7c
Created January 21, 2015 13:43
medium, creating a login screen, simple redirect function
var redirectUser = function() {
if ( attrs.redirects !== undefined) {
var redirects = JSON.parse(attrs.redirects);
if (redirects.show_welcome) {
$location.path('/welcome');
} else if (redirects.success_url) {
$location.path(redirects.success_url);
}
}
};
@simonmorley
simonmorley / gist:ce7e31bb50433b0d1011
Created January 21, 2015 14:49
Medium, creating a login screen, welcome service
welcome: {
cache: true,
method: 'GET',
isArray: false,
params: {
v: 2,
welcome: true
}
}
@simonmorley
simonmorley / gist:675b9e5c7e7583d92ebf
Last active August 29, 2015 14:13
Medium, creating a splash, welcome directive
app.directive('welcome', ['$routeParams', '$location', '$window', 'Login', '$timeout', function($routeParams, $location, $window, Login, $timeout) {
var link = function(scope,element,attrs) {
scope.loading = true;
var request_uri = $location.host();
var apMac = $routeParams.mac || $routeParams.sip;
Login.welcome({request_uri: request_uri, mac: apMac}).$promise.then(function(results) {
@simonmorley
simonmorley / gist:67ee511ab09a79da3498
Created January 21, 2015 16:27
medium, creating an interceptor to device device types
app.factory('apInterceptor', ['$q', '$location', '$rootScope', '$routeParams', 'DEVICES',
function($q, $location, $rootScope, $routeParams, DEVICES) {
return {
request: function(config) {
var setDevice = function() {
if ($routeParams.uamip !== undefined && $routeParams.uamport !== undefined) {
$rootScope.deviceId = DEVICES.ct;
} else if ( $routeParams.switchip !== undefined && $routeParams.cmd !== undefined ) {
@simonmorley
simonmorley / gist:a81638e9a730b1120f67
Created January 21, 2015 16:28
medium, creating an interceptor to device device constants
app.constant('DEVICES', {
ct: '1',
aruba: '2',
meraki: '3',
ruckus: '4',
aerohive: '5',
xirrus: '6',
unknown: '999'
});
@simonmorley
simonmorley / gist:01c57872049b42fee3ab
Created January 21, 2015 19:09
Expected responses from Aruba APS via curl
Failed login
<html>
<head>
<meta http-equiv="refresh" content="0; url=http://polkaspots.my-wifi.co:80/4215309485667105204?url=http://www.google.com&mac=xxx&ip=172.31.99.17&essid=PolkaSpots-ARB&apname=18:64:72:c6:3c:e8&apgroup=instant-C6:3C:E8&errmsg=Login error. Please retry.">
</head><body></body>
</html>
Successful login
@simonmorley
simonmorley / gist:80943bda859a3f39e375
Created January 22, 2015 12:15
medium, creating a login, integrating meraki, creating a cllient.details service
app.factory('Client', ['$routeParams',
function($routeParams) {
var details = function() {
return $routeParams;
};
return {
details: details
@simonmorley
simonmorley / gist:63cd5d944ce4af5a2ccb
Last active August 29, 2015 14:13
medium, creating a login, integrating meraki, creating a cllient.details service full
var app = angular.module('ctLoginsApp.tony.services', ['ngResource']);
app.factory('Client', ['$routeParams', '$q', '$rootScope', '$location',
function($routeParams, $q, $rootScope, $location) {
var clientMac, apMac, redirectUri, loginUri, apTags, requestUri;
var details = function() {
var deferred = $q.defer();