Skip to content

Instantly share code, notes, and snippets.

View edy's full-sized avatar

Eduard Baun edy

  • Paderborn, Germany
View GitHub Profile

so you'd do something like:

var isAllowedTo = require('../api/policies/isAllowedTo');
module.exports = {
  UserController: {
    create: isAllowedTo('createUser')
  }
}

I am keeping this as a reference to balderdashy/sails#352

Working with SailsJS v0.10-rc5: I am trying to keep the magic of blueprint controllers while at the same time protecting some model attributes from being changed by users on the default routes. I.e.: prevent access to the is_admin attribute on regular CRUD routes and implement a promote action or something similar on the UserController which makes the neccessary checks.

In order to do this, I came up with the following policy in combination with a small addition to the model definitions:

// file: api/policies/protectedAttributes.js

/**

'use strict';
var actionUtil = require('sails/lib/hooks/blueprints/actionUtil');
/**
* todo
*
* @param {Request} request Request object
* @param {Response} response Response object
* @param {Function} next Callback function
@edy
edy / Rights.js
Created August 23, 2014 11:48 — forked from tarlepp/Rights.js
'use strict';
var _ = require('lodash');
var actionUtil = require('sails/lib/hooks/blueprints/actionUtil');
/**
* Service function which adds necessary object specified conditions to Project
* model queries. Workflow with this is following:
*
* 1) Fetch project ids where current user is attached to
'use strict';
/**
* frt-nav directive
* should be used within bootstrap navigations to set the 'active' class on current active link (li-element)
* dom should look like this:
* <ul frt-nav>
* <li>
* <a ui-sref="stateName">linkName</a>
* </li>
@edy
edy / TV-Browser-Benachrichtigungen.md
Last active August 29, 2015 14:07
TV-Browser-Benachrichtigungen (Mitteilungszentrale / Notification Center) unter OS X Mavericks einrichten

  1. terminal-notifier installieren,
  2. TV-Browser-Einstellungen öffnen,
  3. Plugins --> Erinnerer,
  4. "Applikation ausführen" aktivieren,
  5. "Konfigurieren" anklicken,
  6. Applikation: /Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier,
  7. Parameter: -sender tvbrowser.TVBrowser -title "{title}" -message "{channel_name} / {leadingZero(start_hour, "1")}:{leadingZero(start_minute, "1")}Uhr" -subtitle "{episode}"
$colors: (
1: $blog-navigation-color1,
2: $blog-navigation-color2,
3: $blog-navigation-color3,
4: $blog-navigation-color4,
5: $blog-navigation-color5
);
@each $color in $colors {
$nr: nth($color, 1);
$color: nth($color, 2);
@edy
edy / iterator.scss
Last active August 29, 2015 14:21
SCSS nth-child(n) iterator
// frontpage widget colors
$frontpage-widget-color1: #00B5CC;
$frontpage-widget-color2: $green;
$frontpage-widget-color3: #CC181E; // youtube-rot
$frontpage-widget-icon1: "\f086"; // comments
$frontpage-widget-icon2: "\f007"; // user
$frontpage-widget-icon3: "\f16a"; // youtube-play
$colors: (
@edy
edy / ntfs-3g
Created July 29, 2015 20:56
fix for "autofs: ntfs-3g: Unknown option '-s'"
#!/bin/bash
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=787779
exec /bin/ntfs-3g.orig ${*/-s/}
@edy
edy / ep.json
Created March 14, 2012 16:18
Ein DDI-Plugin für Etherpad Lite
{
"parts": [
{
"name": "ddi-plugin",
"hooks": {
"expressCreateServer": "ep_ddi/plugin:expressServer"
}
}
]
}