|
@@ -0,0 +1,33 @@
|
|
1
|
+var AuthUtil = {
|
|
2
|
+ /**
|
|
3
|
+ * Creates the URL pointing to JWT token authentication service. It is
|
|
4
|
+ * formatted from the 'urlPattern' argument which can contain the following
|
|
5
|
+ * constants:
|
|
6
|
+ * '{room}' - name of the conference room passed as <tt>roomName</tt>
|
|
7
|
+ * argument to this method.
|
|
8
|
+ * '{roleUpgrade}' - will contain 'true' if the URL will be used for
|
|
9
|
+ * the role upgrade scenario, where user connects from anonymous domain and
|
|
10
|
+ * then gets upgraded to the moderator by logging-in from the popup window.
|
|
11
|
+ *
|
|
12
|
+ * @param urlPattern a URL pattern pointing to the login service
|
|
13
|
+ * @param roomName the name of the conference room for which the user will
|
|
14
|
+ * be authenticated
|
|
15
|
+ * @param {bool} roleUpgrade <tt>true</tt> if the URL will be used for role
|
|
16
|
+ * upgrade scenario, where the user logs-in from the popup window in order
|
|
17
|
+ * to have the moderator rights granted
|
|
18
|
+ *
|
|
19
|
+ * @returns {string|null} the URL pointing to JWT login service or
|
|
20
|
+ * <tt>null</tt> if 'urlPattern' is not a string and the URL can not be
|
|
21
|
+ * constructed.
|
|
22
|
+ */
|
|
23
|
+ getTokenAuthUrl: function (urlPattern, roomName, roleUpgrade) {
|
|
24
|
+ var url = urlPattern;
|
|
25
|
+ if (typeof url !== "string") {
|
|
26
|
+ return null;
|
|
27
|
+ }
|
|
28
|
+ return url.replace("{room}", roomName)
|
|
29
|
+ .replace("{roleUpgrade}", roleUpgrade === true);
|
|
30
|
+ }
|
|
31
|
+};
|
|
32
|
+
|
|
33
|
+module.exports = AuthUtil;
|