Skip to content

term::login() doesn't work with term::push() #980

@jcubic

Description

@jcubic

terminal::login() is documented but it don't work quite right.

Login only works when used in terminal option or with push(). But it should also work when called implicitly after the push().

const term = $('body').terminal({
    auth() {
        term.push(command => {
            term.echo(`protected command <white>${command}</white>`);
        }, {
            prompt: '# '
        }).login(function(username, password) {
            if (username == 'demo' && password == 'demo') {
                return '<TOKEN>';
            }
            return null;
        });
    }
}, {
    completion: true,
    prompt: '$ '
});

This doesn't work when user is already authenticated.

Steps to reproduce

  1. Open repro
  2. type auth and demo:demo as login and password
  3. refresh the page
  4. type auth

Actual behavior

The terminal is paused, when you press CTRL+D you're logged in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugresolvedif issue is resolved, it will be open until merge with master

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions