Skip to content

Commit

Permalink
resume when calling login when already authenticated #980
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Oct 29, 2024
1 parent f791b4d commit be21248
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## 2.45.0
### Features
* add `id` option that allow to create same terminal using hot reload [#978](https://github.com/jcubic/jquery.terminal/issues/978)
### Bugfix
* fix `terminal::login()` when user already authenticated [#980](https://github.com/jcubic/jquery.terminal/issues/980)

## 2.44.1
### Bugfix
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
[![Build and test](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&3a08274fb3d1c4cbcdf3ca25c25dabb7)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&1620e1f399d74967a5e6292177558e0a)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
![NPM Downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
[![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded&n=1)](https://www.jsdelivr.com/package/npm/jquery.terminal)
[![Paid Support](https://img.shields.io/badge/paid-support-354465.svg)](https://support.jcubic.pl/)
Expand Down
12 changes: 12 additions & 0 deletions __tests__/terminal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5879,6 +5879,18 @@ describe('Terminal plugin', function() {
expect(term.get_prompt()).toEqual('>>> ');
term.logout(true).pop().pop();
});
it('should login when already auth', function() {
term.push($.noop, {prompt: '>>> '}).login(login.callback, true);
if (term.token(true)) {
term.logout(true);
}
enter(term, 'foo');
enter(term, 'bar');
expect(term.token(true)).toEqual(token);
term.login(login.callback, true);
expect(term.paused()).toBe(false);
term.logout(true).pop().pop();
});
it('should login to nested interpreter when using login option', function() {
term.push($.noop, {
prompt: '$$$ ',
Expand Down
2 changes: 2 additions & 0 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -9936,6 +9936,8 @@
if (valid !== false) {
if (is_function(success)) {
success();
} else {
self.resume();
}
} else {
self.resume();
Expand Down
20 changes: 14 additions & 6 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
* / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
* \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
* \/ /____/ version 2.44.1
* \/ /____/ version DEV
*
* This file is part of jQuery Terminal. https://terminal.jcubic.pl
*
Expand Down Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sat, 26 Oct 2024 19:45:38 +0000
* Date: Tue, 29 Oct 2024 22:55:22 +0000
*/
/* global define, Map, BigInt */
/* eslint-disable */
Expand Down Expand Up @@ -1522,7 +1522,9 @@
set: function(index, value) {
if (!data[index]) {
data[index] = value;
return true;
}
return false;
},
append: function(item) {
data.push(item);
Expand Down Expand Up @@ -5347,8 +5349,8 @@
}
// -------------------------------------------------------------------------
$.terminal = {
version: '2.44.1',
date: 'Sat, 26 Oct 2024 19:45:38 +0000',
version: 'DEV',
date: 'Tue, 29 Oct 2024 22:55:22 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -7668,7 +7670,9 @@
invalidMask: 'Invalid mask used only string or boolean allowed',
defunctTerminal: "You can't call method '%s' on terminal that was destroyed",
abortError: 'Abort with CTRL+D',
timeoutError: 'Signal timed out'
timeoutError: 'Signal timed out',
invalidId: 'terminal with this `id` aready exists! You need to destr' +
'oy old terminal before you can create terminal with the same `id`'
}
};
// -------------------------------------------------------------------------
Expand Down Expand Up @@ -9932,6 +9936,8 @@
if (valid !== false) {
if (is_function(success)) {
success();
} else {
self.resume();
}
} else {
self.resume();
Expand Down Expand Up @@ -12075,7 +12081,9 @@
global_login_fn = make_json_rpc_login(base_interpreter, settings.login);
}
if (have_custom_id) {
terminals.set(settings.id, self);
if (!terminals.set(settings.id, self)) {
warn(strings().invalidId);
}
} else {
terminals.append(self);
}
Expand Down
6 changes: 3 additions & 3 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/jquery.terminal.min.js.map

Large diffs are not rendered by default.

0 comments on commit be21248

Please sign in to comment.