-
Notifications
You must be signed in to change notification settings - Fork 538
/
Copy pathidentity.js
59 lines (49 loc) · 1.34 KB
/
identity.js
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
/*package annotator.identity */
"use strict";
var SimpleIdentityPolicy;
/**
* function:: simple()
*
* A module that configures and registers an instance of
* :class:`annotator.identity.SimpleIdentityPolicy`.
*/
exports.simple = function simple() {
var identity = new SimpleIdentityPolicy();
return {
configure: function (registry) {
registry.registerUtility(identity, 'identityPolicy');
},
beforeAnnotationCreated: function (annotation) {
annotation.user = identity.who();
}
};
};
/**
* class:: SimpleIdentityPolicy
*
* A simple identity policy that considers the identity to be an opaque
* identifier.
*/
SimpleIdentityPolicy = function SimpleIdentityPolicy() {
/**
* data:: SimpleIdentityPolicy.identity
*
* Default identity. Defaults to `null`, which disables identity-related
* functionality.
*
* This is not part of the identity policy public interface, but provides a
* simple way for you to set a fixed current user::
*
* app.ident.identity = 'bob';
*/
this.identity = null;
};
exports.SimpleIdentityPolicy = SimpleIdentityPolicy;
/**
* function:: SimpleIdentityPolicy.prototype.who()
*
* Returns the current user identity.
*/
SimpleIdentityPolicy.prototype.who = function () {
return this.identity;
};