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
defmodule RestAuth.RestAuthHandler do | |
use Behaviour | |
@doc "Loads a user from the database, will be used by `get_user_roles/1` function and ´get_user_metadata/1` functions" | |
defcallback load_user(username :: String.t, password :: String.t) :: Any | |
@doc "Fetches user roles from user object" | |
defcallback get_user_roles(user :: Any) :: [] | |
@doc "Returns default set of roles, for example `[\"ROLE_USER\"]`." |
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
iex(15)> {:ok,payload} = Poison.encode %{"user_id" => 1, "roles" => ["admin", "user"], "metadata" => %{"foo" => "bar"}} | |
{:ok, | |
"{\"user_id\":1,\"roles\":[\"admin\",\"user\"],\"metadata\":{\"foo\":\"bar\"}}"} | |
iex(16)> token = Phoenix.Token.sign(Core.Endpoint, "bar", payload) | |
"g3QAAAACZAAEZGF0YW0AAAA/eyJ1c2VyX2lkIjoxLCJyb2xlcyI6WyJhZG1pbiIsInVzZXIiXSwibWV0YWRhdGEiOnsiZm9vIjoiYmFyIn19ZAAGc2lnbmVkbgYAaGwXbk8B--7TCEz5KiWYV4F8lPc5dbJjbpsAE=" | |
iex(17)> {:ok,decoded} = Phoenix.Token.verify(Core.Endpoint, "bar", token) | |
{:ok, | |
"{\"user_id\":1,\"roles\":[\"admin\",\"user\"],\"metadata\":{\"foo\":\"bar\"}}"} | |
iex(18)> |
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
defmodule Core.OpensipsClusterView do | |
use Core.Web, :view | |
def render("index.json", %{opensips_clusters: opensips_clusters}) do | |
%{data: render_many(opensips_clusters, Core.OpensipsClusterView, "opensips_cluster.json")} | |
end | |
def render("show.json", %{opensips_cluster: opensips_cluster}) do | |
%{data: render_one(opensips_cluster, Core.OpensipsClusterView, "opensips_cluster.json")} | |
end |
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
/*--- QUERY ---*/ | |
self.query = { | |
projects: ko.observableArray(<%= projectIDs %>), //we start with all projects checked | |
outcrops: ko.observableArray([]), | |
grossDepositionalEnvironment: ko.observable(""), | |
depositionalEnvironment: ko.observable(""), | |
mainClimate: ko.observableArray([]), | |
depositionalSubEnvironment: ko.observable(""), | |
architecturalElement: ko.observable(""), | |
//filters |
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
def crit = Teacher.createCriteria() | |
def teacherList = crit.list { | |
classes { | |
eq('id', classInstance.id) | |
} | |
} |
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
<?php | |
//============================================================+ | |
// File name : example_001.php | |
// Begin : 2008-03-04 | |
// Last Update : 2013-05-14 | |
// | |
// Description : Example 001 for TCPDF class | |
// Default Header and Footer | |
// | |
// Author: Nicola Asuni |
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
/* jshint node: true */ | |
'use strict'; | |
var gulp = require('gulp'), | |
g = require('gulp-load-plugins')({lazy: false}), | |
noop = g.util.noop, | |
es = require('event-stream'), | |
queue = require('streamqueue'), | |
lazypipe = require('lazypipe'), | |
stylish = require('jshint-stylish'), |
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('safariFront.common', ['safariFront.commonServices']) | |
.controller('RegistrationModalController', ['$scope', function($scope) { | |
$scope.companies = {} //will show you new fancy rest thing later | |
}]) | |
.controller('BodyController',['$scope', 'LoginService', function($scope, LoginService) { | |
'use strict'; | |
$scope.topTitle = "Home"; | |
$scope.user = LoginService.getUser(); |
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
package no.cipr.safari.auxiliary | |
class Page { | |
String pageName, title, content | |
Boolean secured | |
static constraints = { | |
pageName(unique: true, blank: false) |
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
@Secured('IS_AUTHENTICATED_ANONYMOUSLY') | |
def test() { | |
respond UserRole.withCriteria { | |
role { | |
eq('authority', 'ROLE_COMPANY_ADMIN') | |
} | |
} | |
} | |
OlderNewer