Browse code

gamatomic cookie

devnewton authored on 19/04/2018 13:26:34
Showing 2 changed files
... ...
@@ -154,20 +154,32 @@ jb3 = {
154 154
     },
155 155
     postCurrentMessage: function () {
156 156
         var selectedRoom = this.controlsRoom.val();
157
-        var auth = localStorage.getItem("dlfp-auth")
158
-        if (this.checkAuth(auth, selectedRoom)) {
157
+        var auth = this.checkAuth(selectedRoom);
158
+        if (auth) {
159 159
             this.postMessage(this.controlsNickname.val(), this.controlsMessage.val(), selectedRoom, auth);
160 160
             this.controlsMessage.val('');
161 161
         }
162 162
     },
163
-    checkAuth: function (auth, selectedRoom) {
163
+    checkAuth: function (selectedRoom) {
164 164
         if (selectedRoom === 'dlfp') {
165
+            var auth = localStorage.getItem("dlfp-auth");
165 166
             if (this.checkIfDlfpTokenIsExpired(auth)) {
166 167
                 window.location.href = "/dlfp/connect";
167 168
                 return false;
169
+            } else {
170
+                return auth;
171
+            }
172
+        } else if(selectedRoom === 'gamatomic') {
173
+            var auth =  localStorage.getItem('gamatomic-auth');
174
+            if(auth) {
175
+                return auth;
176
+            } else {
177
+                window.alert("Please configure gamatomic cookie (in rooms page)");
178
+                return false;
168 179
             }
180
+        } else {
181
+            return true;
169 182
         }
170
-        return true;
171 183
     },
172 184
     checkIfDlfpTokenIsExpired: function (authStr) {
173 185
         if (!authStr) {
... ...
@@ -5,6 +5,10 @@ riot.tag(
5 5
                 <form action="/dlfp/connect" class="o-form-element" if="{ rname.value == \'dlfp\' }">\
6 6
                         <input type="submit" class="c-button c-button--info" value="Connect & authorize">\
7 7
                 </form>\
8
+                <div class="o-form-element" if="{ rname.value == \'gamatomic\' }">\
9
+                        <label class="c-label" for="gamatomicAuk">Cookie:</label>\
10
+                        <input name="gamatomicAuk" type="text" class="c-field" placeholder="Paste Auk cookie here" onchange="{ save }">\
11
+                </div>\
8 12
 		<div class="c-input-group" if="{ !rname.value }">\
9 13
                     <input name="rname" class="c-field" type="text" placeholder="Type new room\'s name">\
10 14
                     <button if="{ !rname.value }" class="c-button c-button--info" onclick="{ save }">Create new room</button>\
... ...
@@ -12,6 +16,7 @@ riot.tag(
12 16
 		<div class="o-form-element" if="{ !rname.value }" >\
13 17
                     <button class="c-button c-button--warning" onclick="{ resetAll }">Reset all rooms</button>\
14 18
 		</div>\
19
+                 <button if="{ rname.value == \'gamatomic\' }" class="c-button c-button--info" onclick="{ save }">Save</button>\
15 20
 		<button if="{ rname.value }" class="c-button" onclick="{ cancel }">Cancel</button>\
16 21
 		<button if="{ rname.value }" class="c-button c-button--warning" onclick="{ del }">Delete</button>\
17 22
 </fieldset>\
... ...
@@ -27,6 +32,9 @@ riot.tag(
27 32
 							this.trigger('save-room', {
28 33
 								rname : this.rname.value
29 34
 							});
35
+                                                        if(this.gamatomicAuk) {
36
+                                                            localStorage.setItem('gamatomic-auth', this.gamatomicAuk.value);
37
+                                                        }
30 38
 							this.rname.value = '';
31 39
 							this.update();
32 40
 						}