This file contains 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
angular.module('angularAuth', ['ngCookies']) | |
.config([ | |
'$routeProvider', | |
'$locationProvider', | |
'$httpProvider', | |
function ($routeProvider, $locationProvider, $httpProvider) { | |
// ... | |
var interceptor = ['$location', '$q', function($location, $q) { |
This file contains 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
angular.module('angular-client-side-auth') | |
.directive('accessLevel', ['$rootScope', 'Auth', function($rootScope, Auth) { | |
return { | |
restrict: 'A', | |
link: function(scope, element, attrs) { | |
var prevDisp = element.css('display'); | |
$rootScope.$watch('user.role', function(role) { | |
if(!Auth.authorize(attrs.accessLevel)) | |
element.css('display', 'none'); | |
else |
This file contains 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
User.remove({}, function(err) { | |
if(err) { return done(err); } | |
Exercise.remove({}, function(err) { | |
if(err) { return done(err); } | |
WorkoutTemplate.remove({}, function(err) { | |
if(err) { return done(err); } | |
User.create(require('../../data/users.json'), function(err) { |
This file contains 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
var mongoose = require('mongoose'); | |
mongoose.Model.seed = function(entities) { | |
var promise = new mongoose.Promise; | |
this.create(entities, function(err) { | |
if(err) { promise.reject(err); } | |
else { promise.resolve(); } | |
}); | |
return promise; | |
}; |
This file contains 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
beforeEach(function(done) { | |
// ... | |
// Reset collections | |
User.remove().exec() | |
.then(function() { return Exercise.remove().exec() }) | |
.then(function() { return WorkoutTemplate.remove().exec() }) | |
// Seed |
This file contains 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
module.exports = function(grunt) { | |
// Load plugins | |
grunt.loadNpmTasks('grunt-manifest'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
// Make a list of paths/files to cache | |
var cache = ['./public/js/*', './public/img/*', './public/css/*']; | |
grunt.initConfig({ |
This file contains 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
var routes = [ | |
// Partial views | |
{ | |
path: '/partials/*', | |
httpMethod: 'GET', | |
middleware: [function (req, res) { | |
var requestedView = path.join('./', req.url); | |
res.render(requestedView); | |
}] | |
}, |
This file contains 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
var routes = [ | |
'/partials': { | |
accessLevel: access.admin, // Access level for all /partials sub routes | |
subRoutes: [{ | |
// Full URL: /partials/ | |
'/': { | |
templateUrl: 'partials/index', | |
controller: partialsCtrl | |
}, |
This file contains 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
var routes = [ | |
'/partials': { | |
accessLevel: access.admin, // Access level for all /partials sub routes | |
subRoutes: [{ | |
// Full URL: /partials/ | |
'/': { | |
templateUrl: 'partials/index', | |
controller: partialsCtrl | |
}, |
This file contains 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
<button access-level="accessLevels.user">Add</button> | |
<button access-level="accessLevels.user">Edit</button> | |
<button access-level="accessLevels.admin">Delete</button> |