-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorganizations-module.html
271 lines (267 loc) · 11.8 KB
/
organizations-module.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<html data-navbar="navbar.html">
<head>
<title>Organizations module documentation</title>
<link rel="stylesheet" href="/public/style.css" integrity="sha384-XmYAsTgQ0mGje5sxXJRryYc/mmaL3bnA+Hn9kHkpyRTgdpgM220bOzj5BgWZ41jo" crossorigin="anonymous" />
<script async="" src="/public/highlight.min.js" integrity="sha384-YicwDnP9OMQKl5DfX4/eDA3oUGqPTcuyq0+eFbwv595VqixFKEgoO/T8TxD0tjB8" crossorigin="anonymous"></script>
<script src="/public/browser.js" integrity="sha384-pNXFiUIAMNO/S1fGF4GF3fq8OV5x2fZdicewcpuMG/2EOOJ7+HH3no0GDKTePhCD" crossorigin="anonymous"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="UTF-8" />
<body><a name="top" id="top"></a>
<div class="body-container">
<header>
<h1 id="dashboard">Organizations module documentation</h1>
<section id="navigation" class="navigation">
<menu id="navbar-handle" class="super-navbar" style="display: none">
<li><a href="#" title="Show menu">Show navigation menu</a></li>
</menu>
<ul id="navbar-menu" style="display: block">
<li>
<h2>Dashboard</h2>
<ul>
<li><a href="/dashboard">Documentation</a></li>
<li><a href="/dashboard-configuration">Configuration variables</a></li>
<li><a href="/dashboard-sitemap">Visual sitemap</a></li>
<li><a href="/dashboard-ui">UI index</a></li>
<li><a href="/dashboard-api">API index</a></li>
</ul>
</li>
<li>
<h2>MaxMind GeoIP</h2>
<ul>
<li><a href="/maxmind-geoip-module">Documentation</a></li>
<li><a href="/maxmind-geoip-api">API index</a></li>
</ul>
</li>
<li>
<h2>Organizations</h2>
<ul>
<li><a href="/organizations-module">Documentation</a></li>
<li><a href="/organizations-configuration">Configuration variables</a></li>
<li><a href="/organizations-sitemap">Visual sitemap</a></li>
<li><a href="/organizations-ui">UI index</a></li>
<li><a href="/organizations-api">API index</a></li>
</ul>
</li>
<li>
<h2>Stripe Connect</h2>
<ul>
<li><a href="/stripe-connect-module">Documentation</a></li>
<li><a href="/stripe-connect-configuration">Configuration variables</a></li>
<li><a href="/stripe-connect-sitemap">Visual sitemap</a></li>
<li><a href="/stripe-connect-ui">UI index</a></li>
<li><a href="/stripe-connect-api">API index</a></li>
</ul>
</li>
<li>
<h2>Stripe Subscriptions</h2>
<ul>
<li><a href="/stripe-subscriptions-module">Documentation</a></li>
<li><a href="/stripe-subscriptions-configuration">Configuration variables</a></li>
<li><a href="/stripe-subscriptions-sitemap">Visual sitemap</a></li>
<li><a href="/stripe-subscriptions-ui">UI index</a></li>
<li><a href="/stripe-subscriptions-api">API index</a></li>
</ul>
</li>
<li>
<h2>Example app</h2>
<ul>
<li><a href="/example-web-app">Documentation</a></li>
<li><a href="/example-web-app-sitemap">Visual sitemap</a></li>
<li><a href="/example-web-app-ui">UI index</a></li>
</ul>
</li>
<li>
<h2>Example subscription app</h2>
<ul>
<li><a href="/example-subscription-web-app">Documentation</a></li>
<li><a href="/example-subscription-web-app-sitemap">Visual sitemap</a></li>
<li><a href="/example-subscription-web-app-ui">UI index</a></li>
</ul>
</li>
</ul>
<style>
.reveal,
.reveal ul {
display: block
}
</style>
<script>
var menu = document.getElementById("navbar-menu")
menu.style.display = "none"
var handle = document.getElementById("navbar-handle")
handle.style.display = "block"
handle.onclick = function(e) {
if (menu.style.display === "block") {
menu.style.display = "none"
menu.className = ""
handle.firstElementChild.firstElementChild.innerHTML = "Show navigation menu"
} else {
menu.style.display = "block"
menu.className = "reveal"
handle.firstElementChild.firstElementChild.innerHTML = "Hide navigation menu"
}
}
</script>
</section>
</header>
<div class="section-container">
<section class="full"><a name="content" id="content"></a>
<div class="content">
<h1 id="documentation-for-organizations">Documentation for Organizations</h1>
<h4>Index</h4>
<ul>
<li><a href="#organizations-module">Introduction</a></li>
<li><a href="#module-contents">Module contents</a></li>
<li><a href="#import-this-module">Import this module</a></li>
<li><a href="#storage-engine">Storage engine</a></li>
<li><a href="#customizing-membership-profiles">Customizing membership profiles</a></li>
<li><a href="#access-the-api">Access the API</a></li>
<li><a href="https://github.com/userdashboard/organizations">Github repository</a></li>
<li><a href="https://npmjs.org/userdashboard/organizations">NPM package</a></li>
</ul>
<h1 id="introduction">Introduction</h1>
<p>Dashboard bundles everything a web app needs, all the "boilerplate" like signing in and changing passwords, into a parallel server so you can write a much smaller web app.</p>
<p>The Organizations module allows users to create organizations and invitations other users can accept to join. Users must share the invitations themselves with the recipients. Your application server can use the Organizations module's API to fetch what organizations a user is in and use that data to allow shared access or assign ownership or whatever other purpose. A complete UI is provided for users to create and manage their organizations and memberships, and a basic administrator UI is provided for oversight.</p>
<h1 id="module-contents">Module contents</h1>
<p>Dashboard modules can add pages and API routes. For more details check the <code data-language="js">sitemap.txt</code> and <code data-language="js">api.txt</code> or <code data-language="js">env.txt</code> also contained in the online documentation.</p>
<table>
<thead>
<tr>
<th>Content type</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Proxy scripts</td>
<td></td>
</tr>
<tr>
<td>Server scripts</td>
<td></td>
</tr>
<tr>
<td>Content scripts</td>
<td></td>
</tr>
<tr>
<td>User pages</td>
<td>Yes</td>
</tr>
<tr>
<td>User API routes</td>
<td>Yes</td>
</tr>
<tr>
<td>Administrator pages</td>
<td>Yes</td>
</tr>
<tr>
<td>Administrator API routes</td>
<td>Yes</td>
</tr>
</tbody>
</table>
<h2 id="import-this-module">Import this module</h2>
<p>On your Dashboard server you need to install this module with NPM:</p>
<pre><code data-language="js">$ npm install @userdashboard/organizations
</code></pre>
<p>Edit your <code data-language="js">package.json</code> to activate the module:</p>
<pre><code data-language="js">"dashboard": {
"modules": [
"@userdashboard/organizations"
]
}
</code></pre>
<h2 id="storage-engine">Storage engine</h2>
<p>By default this module will share whatever storage you use for Dashboard. You can specify an alternate storage module to use instead, or the same module with a separate database.</p>
<pre><code data-language="js">ORGANIZATIONS_STORAGE=@userdashboard/storage-mongodb
ORGANIZATIONS_MONGODB_URL=mongo://localhost:27017/organizations
</code></pre>
<h1 id="customizing-membership-profiles">Customizing membership profiles</h1>
<p>Memberships designate a Profile which you can configure to collect the information relevant to your organizations. You specify the fields you want in an environment variable:</p>
<pre><code data-language="js">MEMBERSHIP_PROFILE_FIELDS="any,of,the,below"
</code></pre>
<table>
<thead>
<tr>
<th>Field</th>
</tr>
</thead>
<tbody>
<tr>
<td>display-name</td>
</tr>
<tr>
<td>display-email</td>
</tr>
<tr>
<td>contact-email</td>
</tr>
<tr>
<td>full-name</td>
</tr>
<tr>
<td>dob</td>
</tr>
<tr>
<td>phone</td>
</tr>
<tr>
<td>occupation</td>
</tr>
<tr>
<td>location</td>
</tr>
<tr>
<td>location</td>
</tr>
<tr>
<td>company-name</td>
</tr>
<tr>
<td>website</td>
</tr>
</tbody>
</table>
<h3 id="access-the-api">Access the API</h3>
<p>Dashboard and official modules are completely API-driven and you can access the same APIs on behalf of the user making requests. You perform <code data-language="js">GET</code>, <code data-language="js">POST</code>, <code data-language="js">PATCH</code>, and <code data-language="js">DELETE</code> HTTP requests against the API endpoints to fetch or modify data. This example fetches the user's country information using NodeJS, you can do this with any language:</p>
<p>You can view API documentation within the NodeJS modules' <code data-language="js">api.txt</code> files, or on the <a href="https://userdashboard.github.io/organizations-api">documentation site</a>.</p>
<pre><code data-language="js">const memberships = await proxy(`/api/user/organizations/memberships?accountid=${accountid}&all=true`, accountid, sessionid)
const proxy = util.promisify((path, accountid, sessionid, callback) => {
const requestOptions = {
host: 'dashboard.example.com',
path: path,
port: '443',
method: 'GET',
headers: {
'x-application-server': 'application.example.com',
'x-application-server-token': process.env.APPLICATION_SERVER_TOKEN,
'x-accountid': accountid,
'x-sessionid': sessionid
}
}
const proxyRequest = require('https').request(requestOptions, (proxyResponse) => {
let body = ''
proxyResponse.on('data', (chunk) => {
body += chunk
})
return proxyResponse.on('end', () => {
return callback(null, JSON.parse(body))
})
})
proxyRequest.on('error', (error) => {
return callback(error)
})
return proxyRequest.end()
})
}
</code></pre>
</div>
<p><a href="#top">Top of page</a></p>
</section>
</div>
</div>
</body>
</head>
</html>