omniauth-centro 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,119 @@
|
|
1
|
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
|
2
|
+
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
|
3
|
+
|
4
|
+
<link href="http://wwwendt.de/tech/dynatree/src/skin/ui.dynatree.css" rel="stylesheet" type="text/css">
|
5
|
+
<script src="http://wwwendt.de/tech/dynatree/src/jquery.dynatree.js" type="text/javascript"></script>
|
6
|
+
|
7
|
+
<script type="text/javascript">
|
8
|
+
var updateRawInfoJsonFromTree = function() {
|
9
|
+
var rawInfo = { organizations: [], memberships: [] };
|
10
|
+
var products = {};
|
11
|
+
var organization_owner = {};
|
12
|
+
var tree = getTree();
|
13
|
+
var selectedOrganizationId = null;
|
14
|
+
|
15
|
+
tree.visit(function(node) {
|
16
|
+
if (node.data.product_name) {
|
17
|
+
organization_id = node.data.organization_id;
|
18
|
+
|
19
|
+
if (products[organization_id] == null) {
|
20
|
+
products[organization_id] = [];
|
21
|
+
}
|
22
|
+
|
23
|
+
if (node.bSelected == true) {
|
24
|
+
products[organization_id].push(node.data.product_name);
|
25
|
+
selectedOrganizationId = organization_id;
|
26
|
+
}
|
27
|
+
} else if (node.data.title == "organization_owner") {
|
28
|
+
organization_owner[node.data.organization_id] = node.bSelected;
|
29
|
+
}
|
30
|
+
});
|
31
|
+
|
32
|
+
tree.visit(function(node) {
|
33
|
+
if (node.data.id == selectedOrganizationId) {
|
34
|
+
rawInfo.organizations.push({ id: node.data.id, name: node.data.title });
|
35
|
+
}
|
36
|
+
});
|
37
|
+
|
38
|
+
$.each(rawInfo.organizations, function(index, organization) {
|
39
|
+
rawInfo.memberships.push({ organization_id: organization.id, organization_name: organization.name, organization_owner: organization_owner[organization.id], products: products[organization.id] });
|
40
|
+
});
|
41
|
+
|
42
|
+
rawInfo["current_organization_id"] = selectedOrganizationId;
|
43
|
+
$('#raw_info_json')[0].value = JSON.stringify(rawInfo);
|
44
|
+
}
|
45
|
+
|
46
|
+
var ensureSingleOrganizationSelected = function(selectedNode) {
|
47
|
+
getTree().visit(function(node) {
|
48
|
+
if (node.data.id) {
|
49
|
+
node.select(node == selectedNode);
|
50
|
+
node.expand(node == selectedNode);
|
51
|
+
if (node != selectedNode) {
|
52
|
+
node.visit(function(childNode) {
|
53
|
+
childNode.select(false);
|
54
|
+
});
|
55
|
+
}
|
56
|
+
}
|
57
|
+
});
|
58
|
+
}
|
59
|
+
|
60
|
+
var getTree = function() {
|
61
|
+
return $('#raw_info').dynatree('getRoot').tree;
|
62
|
+
}
|
63
|
+
|
64
|
+
$(function() {
|
65
|
+
var product = function(organization_id, organization_name, product_name, selected) {
|
66
|
+
return { title: product_name, organization_id: organization_id, organization_name: organization_name, product_name: product_name, select: selected };
|
67
|
+
}
|
68
|
+
|
69
|
+
var organization = function(id, name, selected) {
|
70
|
+
return { id: id, title: name, expand: selected, key: name, children: [
|
71
|
+
{ title: 'organization_owner', organization_id: id, select: selected },
|
72
|
+
product(id, name, 'mms', selected),
|
73
|
+
product(id, name, 'finance', selected),
|
74
|
+
product(id, name, 'insight', selected),
|
75
|
+
product(id, name, 'planner', selected),
|
76
|
+
product(id, name, 'roz', selected)
|
77
|
+
]
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
var organizations = [
|
82
|
+
organization(1, 'Centro', true),
|
83
|
+
organization(2, 'Test Agency Organization', false),
|
84
|
+
organization(3, 'Test Publisher Organization', false),
|
85
|
+
];
|
86
|
+
|
87
|
+
$("#raw_info").dynatree({
|
88
|
+
checkbox: true,
|
89
|
+
selectMode: 3,
|
90
|
+
children: organizations,
|
91
|
+
autoCollapse: true,
|
92
|
+
onDblClick: function(node, event) {
|
93
|
+
node.toggleSelect();
|
94
|
+
},
|
95
|
+
onKeydown: function(node, event) {
|
96
|
+
if (event.which == 32) {
|
97
|
+
node.toggleSelect();
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
},
|
101
|
+
onSelect: function(flag, node) {
|
102
|
+
if (flag == true) {
|
103
|
+
ensureSingleOrganizationSelected(node);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
});
|
107
|
+
|
108
|
+
$("form").submit(function() {
|
109
|
+
if ($('#email').val() === "") {
|
110
|
+
alert("Email is required!");
|
111
|
+
return false;
|
112
|
+
} else {
|
113
|
+
updateRawInfoJsonFromTree();
|
114
|
+
return true;
|
115
|
+
}
|
116
|
+
});
|
117
|
+
});
|
118
|
+
</script>
|
119
|
+
|
@@ -8,13 +8,7 @@ module OmniAuth
|
|
8
8
|
end
|
9
9
|
|
10
10
|
info do
|
11
|
-
|
12
|
-
:email => raw_info["email"],
|
13
|
-
:organizations => raw_info['organizations'],
|
14
|
-
:features => raw_info['features'],
|
15
|
-
:current_organization_id => raw_info['current_organization_id'],
|
16
|
-
:raw_info => raw_info
|
17
|
-
}
|
11
|
+
raw_info
|
18
12
|
end
|
19
13
|
|
20
14
|
def request_phase
|
@@ -34,71 +28,16 @@ module OmniAuth
|
|
34
28
|
option :uid_field, :email
|
35
29
|
|
36
30
|
def request_phase
|
37
|
-
form = OmniAuth::Form.new(:title => "Centro Developer Login",
|
38
|
-
|
39
|
-
|
31
|
+
form = OmniAuth::Form.new(:title => "Centro Developer Login",
|
32
|
+
:url => callback_path,
|
33
|
+
:header_info => File.read(File.join(File.dirname(__FILE__), "centro.html")))
|
40
34
|
|
41
|
-
<link href="http://wwwendt.de/tech/dynatree/src/skin/ui.dynatree.css" rel="stylesheet" type="text/css">
|
42
|
-
<script src="http://wwwendt.de/tech/dynatree/src/jquery.dynatree.js" type="text/javascript"></script>
|
43
|
-
<script type="text/javascript">
|
44
|
-
var updateRawInfoJsonFromTree = function(tree){
|
45
|
-
var rawInfo = {organizations: [], features: []};
|
46
|
-
$.each(tree.getSelectedNodes(), function(index, node){
|
47
|
-
// This is a "Feature" node
|
48
|
-
if(node.data.key.feature_name){
|
49
|
-
rawInfo.features.push({organization_id: node.data.key.organization_id, name: node.data.key.feature_name});
|
50
|
-
// OTherwise if it has an ID it's an organization
|
51
|
-
}else if(node.data.id){
|
52
|
-
rawInfo.organizations.push({id: node.data.id, name: node.data.title});
|
53
|
-
}
|
54
|
-
});
|
55
|
-
$('#raw_info_json')[0].value = JSON.stringify(rawInfo);
|
56
|
-
}
|
57
|
-
$(function(){
|
58
|
-
var feature = function(organization_id, organization_name, feature_name, selected){
|
59
|
-
return {title: feature_name, key: {organization_id: organization_id, organization_name: organization_name, feature_name: feature_name}, select: selected};
|
60
|
-
}
|
61
|
-
var organization = function(id, name, selected){
|
62
|
-
return {id: id, title: name, expand: true, key: name, children: [
|
63
|
-
feature(id, name,'admin',selected),
|
64
|
-
feature(id, name,'media_plan_creation',selected),
|
65
|
-
feature(id, name,'media_plan_negotiation',selected),
|
66
|
-
feature(id, name,'media_plan_analysis',selected),
|
67
|
-
feature(id, name,'finance',selected)
|
68
|
-
]
|
69
|
-
}
|
70
|
-
}
|
71
|
-
var organizations = [
|
72
|
-
organization(1, 'Centro',true),
|
73
|
-
organization(2, 'CentroTestAgency',false),
|
74
|
-
organization(3, 'CentroTestPublisher',false),
|
75
|
-
];
|
76
|
-
$("#raw_info").dynatree({
|
77
|
-
checkbox: true,
|
78
|
-
selectMode: 3,
|
79
|
-
children: organizations,
|
80
|
-
onSelect: function(select, node) {
|
81
|
-
updateRawInfoJsonFromTree(node.tree);
|
82
|
-
},
|
83
|
-
onDblClick: function(node, event) {
|
84
|
-
node.toggleSelect();
|
85
|
-
},
|
86
|
-
onKeydown: function(node, event) {
|
87
|
-
if( event.which == 32 ) {
|
88
|
-
node.toggleSelect();
|
89
|
-
return false;
|
90
|
-
}
|
91
|
-
},
|
92
|
-
});
|
93
|
-
updateRawInfoJsonFromTree($('#raw_info').dynatree('getRoot').tree);
|
94
|
-
});
|
95
|
-
</script>
|
96
|
-
HTML
|
97
35
|
options.fields.each do |field|
|
98
36
|
form.text_field field.to_s.capitalize.gsub("_", " "), field.to_s
|
99
37
|
end
|
38
|
+
|
100
39
|
form.html "<input type='hidden' id='raw_info_json' name='raw_info_json' />"
|
101
|
-
form.html "<h3>
|
40
|
+
form.html "<h3>Membership</h3>"
|
102
41
|
form.html "<div id='raw_info'></div>"
|
103
42
|
form.button "Sign In"
|
104
43
|
form.to_response
|
@@ -114,7 +53,8 @@ module OmniAuth
|
|
114
53
|
hash
|
115
54
|
end.merge(
|
116
55
|
:organizations => raw_info['organizations'],
|
117
|
-
:
|
56
|
+
:memberships => raw_info['memberships'],
|
57
|
+
:current_organization_id => raw_info['current_organization_id']
|
118
58
|
)
|
119
59
|
end
|
120
60
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-centro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- README.md
|
55
55
|
- lib/omniauth-centro.rb
|
56
56
|
- lib/omniauth-centro/version.rb
|
57
|
+
- lib/omniauth/strategies/centro.html
|
57
58
|
- lib/omniauth/strategies/centro.rb
|
58
59
|
- omniauth-centro.gemspec
|
59
60
|
homepage: https://github.com/centro/omniauth-centro
|