initial commit

This commit is contained in:
Kevin Glisson
2015-06-22 13:47:27 -07:00
commit 4330ac9c05
228 changed files with 16656 additions and 0 deletions

View File

@ -0,0 +1,28 @@
'use strict';
angular.module('lemur')
.config(function config($routeProvider) {
$routeProvider.when('/login', {
templateUrl: '/angular/authentication/login/login.tpl.html',
controller: 'LoginController'
});
})
.controller('LoginController', function ($rootScope, $scope, AuthenticationService, UserService) {
$scope.login = AuthenticationService.login;
$scope.authenticate = AuthenticationService.authenticate;
$scope.logout = AuthenticationService.logout;
UserService.getCurrentUser().then(function (user) {
$scope.currentUser = user;
});
$rootScope.$on('user:login', function () {
UserService.getCurrentUser().then(function (user) {
$scope.currentUser = user;
});
});
$rootScope.$on('user:logout', function () {
$scope.currentUser = null;
});
});

View File

@ -0,0 +1,27 @@
<h2 class="featurette-heading">Login <span class="text-muted"><small>None shall pass</small></span></h2>
<div class="row">
<div class="login">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<button class="btn btn-block btn-default" ng-click="authenticate('ping')">
Login with Meechum
</button>
</div>
</div>
<div class="login-or">
<hr class="hr-or">
<span class="span-or">or</span>
</div>
<form role="form" _lpchecked="1">
<div class="form-group">
<input type="text" ng-model="username" placeholder="Username" class="form-control"/>
</div>
<div class="form-group">
<input type="password" ng-model="password" placeholder="Password" class="form-control"/>
</div>
<div class="form-group">
<button ng-click="login(username, password)" class="btn btn-block btn-success">Login</button>
</div>
</form>
</div>
</div>

View File

@ -0,0 +1,12 @@
'use strict';
angular.module('lemur')
.config(function config($routeProvider) {
$routeProvider.when('/logout', {
controller: 'LogoutCtrl'
});
})
.controller('LogoutCtrl', function ($scope, $location, lemurRestangular, userService) {
userService.logout();
$location.path('/');
});

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,62 @@
'use strict';
angular.module('lemur')
.service('AuthenticationApi', function (LemurRestangular) {
return LemurRestangular.all('auth');
})
.service('AuthenticationService', function ($location, $rootScope, AuthenticationApi, UserService, toaster, $auth) {
var AuthenticationService = this;
AuthenticationService.login = function (username, password) {
AuthenticationApi.customPOST({'username': username, 'password': password}, 'login')
.then(
function (user) {
$auth.setToken(user.token, true);
$rootScope.$emit('user:login');
$location.url('/certificates');
},
function (response) {
toaster.pop({
type: 'error',
title: 'Whoa there',
body: response.data.message,
showCloseButton: true
});
}
);
};
AuthenticationService.authenticate = function (provider) {
$auth.authenticate(provider)
.then(
function (user) {
UserService.getCurrentUser();
$rootScope.$emit('user:login');
$location.url('/certificates');
},
function (response) {
toaster.pop({
type: 'error',
title: 'Something went wrong',
body: response.data.message
});
}
);
}
AuthenticationService.logout = function () {
if (!$auth.isAuthenticated()) {
return;
}
$auth.logout()
.then(function() {
$rootScope.$emit('user:logout');
toaster.pop({
type: 'success',
title: 'Good job!',
body: 'You have been successfully logged out.'
});
$location.path('/');
})
};
});

View File

@ -0,0 +1,18 @@
'use strict';
angular.module('lemur')
.config(function config($routeProvider) {
$routeProvider.when('/unlock', {
templateUrl: '/angular/authentication/unlock/unlock.tpl.html',
controller: 'UnlockCtrl'
});
})
.controller('UnlockCtrl', function ($scope, $location, lemurRestangular, messageService) {
$scope.unlock = function () {
lemurRestangular.one('unlock').customPOST({'password': $scope.password})
.then(function (data) {
messageService.addMessage(data);
$location.path('/dashboard');
});
};
});

View File

@ -0,0 +1,16 @@
<h2 class="featurette-heading">Unlock <span class="text-muted"><small>Assume 9 is twice 5; how will you write 6 times 5 in the same system of notation?</small></span></h2>
<form class="form-horizontal" _lpchecked="1">
<fieldset class="col-lg-offset-4">
<div class="form-group">
<div class="col-lg-4">
<input type="password" ng-model="password" placeholder="Password" class="form-control"/>
</div>
</div>
<hr class="featurette-divider">
<div class="form-group">
<div class="col-lg-4">
<button ng-click="unlock()" class="btn btn-success">Unlock</button>
</div>
</div>
</fieldset>
</form>