Skip to content

Commit c9708ed

Browse files
Log out support with /logout command
1 parent 6606896 commit c9708ed

4 files changed

Lines changed: 37 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"printableName": "Cache Web Terminal",
66
"description": "Web-based terminal emulator for Caché administering.",
77
"author": "ZitRo",
8-
"version": "4.0.0-beta.7",
8+
"version": "4.0.0-beta.8",
99
"gaID": "UA-83005064-2",
1010
"releaseNumber": 26,
1111
"scripts": {

src/client/js/input/special.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,31 @@ export default {
116116
"info": () => {
117117
output.print(locale.get(`info`) + `\r\n`);
118118
},
119+
"logout": () => {
120+
let outcome;
121+
try { outcome = document.execCommand("ClearAuthenticationCache") } catch(e) {}
122+
if (!outcome) {
123+
outcome = ((x) => {
124+
if (!x) return;
125+
if (x) {
126+
x.open("HEAD", location.href, true, "logout",
127+
(new Date()).getTime().toString());
128+
x.send("");
129+
return true;
130+
} else {
131+
return false;
132+
}
133+
})(window.XMLHttpRequest
134+
? new window.XMLHttpRequest()
135+
: ( window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null ))
136+
}
137+
if (!outcome) {
138+
output.printLine(locale.get("unLogOut"));
139+
} else {
140+
output.printLine(locale.get("logOut"));
141+
location.reload();
142+
}
143+
},
119144
"sql": () => {
120145
let sql = terminal.MODE !== Terminal.prototype.MODE_SQL;
121146
terminal.MODE = !sql ? Terminal.prototype.MODE_PROMPT : Terminal.prototype.MODE_SQL;

src/client/js/localization/dictionary.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export default {
152152
\r\x1B[(special)m/config\x1B[0m ...\x1B[32GAllows you to configure WebTerminal's behavior. Enter this command to get more information.
153153
\r\x1B[(special)m/favorite\x1B[0m ...\x1B[32GAllows you to save or restore any freauently used commands. Enter this command to get more information.
154154
\r\x1B[(special)m/info\x1B[0m\x1B[32GShow the information about the WebTerminal project.
155+
\r\x1B[(special)m/logout\x1B[0m\x1B[32GLog out the current WebTerminal user and prompt for the authentication again.
155156
\r\x1B[(special)m/sql\x1B[0m\x1B[32GSwitches terminal to SQL mode. Type SQL commands instead of COS. To exit SQL mode, enter this command again.
156157
\r\x1B[(special)m/trace\x1B[0m ...\x1B[32GEnables global/file tracing. Type this command to get more information.
157158
\r\x1B[(special)m/update\x1B[0m\x1B[32GChecks for available updates.
@@ -167,6 +168,7 @@ export default {
167168
\r\x1B[(special)m/config\x1B[0m ...\x1B[32GПозволяет настраивать поведение веб-терминала. Введите эту команду, чтобы получить больше информации.
168169
\r\x1B[(special)m/favorite\x1B[0m ...\x1B[32GПозволяет сохранять и загружать любые часто используемые команды. Введите эту команду, чтобы получить больше информации.
169170
\r\x1B[(special)m/info\x1B[0m\x1B[32GПоказать информацию про проект веб-терминала.
171+
\r\x1B[(special)m/logout\x1B[0m\x1B[32GВыйти из текущего сеанса и снова пройти аутентификацию.
170172
\r\x1B[(special)m/sql\x1B[0m\x1B[32GПереключить терминал в режим SQL. Далее вводите SQL команды вместо COS. Чтобы выйти из режима SQL, введите эту команду ещё раз.
171173
\r\x1B[(special)m/trace\x1B[0m ...\x1B[32GВключает трассировку глобала/файла. Введите эту команду, чтобы получить больше информации.
172174
\r\x1B[(special)m/update\x1B[0m\x1B[32GПроверяет наличие обновлений.
@@ -334,5 +336,13 @@ export default {
334336
"wsNormalClose": {
335337
en: "Session ended.",
336338
ru: "Сессия закончена."
339+
},
340+
"logOut": {
341+
en: "Logging out...",
342+
ru: "Выходим..."
343+
},
344+
"unLogOut": {
345+
en: "Your browser is too old or too weird to support log out functionality. Please, restart the browser manually.",
346+
ru: "Ваш браузер слишком странный или старый, и он не поддерживает функциональность выхода. Пожалуйста, перезапустите браузер вручную."
337347
}
338348
};

src/client/js/parser/grammar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ rule("CWTSpecial").split(
204204
)
205205
),
206206
id({ value: "info", class: "special" }),
207+
id({ value: "logout", class: "special" }),
207208
id({ value: "sql", class: "special" }),
208209
id({ value: "trace", class: "special" }).whitespace().split(
209210
id({ value: "stop", class: "global" }),

0 commit comments

Comments
 (0)