Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks if no username supplied #1571

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions libcodechecker/libclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
LOG = get_logger('system')


def check_preconfigured_username(username, host, port):
"""
Checks if username supplied by using preconfigured credentials.
"""
if not username:
LOG.error("No username supplied! Please specify the "
"username in your "
"\"~/.codechecker.passwords.json\" file for "
"%s:%s.", host, port)
sys.exit(1)


def check_api_version(auth_client):
"""
Check if server API is supported by the client.
Expand Down Expand Up @@ -123,6 +135,7 @@ def handle_auth(protocol, host, port, username, login=False):
LOG.info("Logging in using preconfigured credentials...")
username = saved_auth.split(":")[0]
pwd = saved_auth.split(":")[1]
check_preconfigured_username(username, host, port)
else:
LOG.info("Logging in using credentials from command line...")
pwd = getpass.getpass("Please provide password for user '{0}': "
Expand Down Expand Up @@ -176,6 +189,8 @@ def perform_auth_for_handler(protocol, manager, host, port,
LOG.info("Logging in using pre-configured credentials...")

username = auto_auth_string.split(':')[0]
check_preconfigured_username(username, host, port)

LOG.debug("Trying to login as '%s' to '%s:%s'", username,
host, port)

Expand Down
7 changes: 7 additions & 0 deletions www/scripts/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ function (declare, cookie, dom, domConstruct, domClass, keys, on, Button,
_doLogin : function() {
var that = this;

// No username supplied.
if (!this.txtUser.value || !this.txtUser.value.trim().length) {
domClass.add(that._mbox.domNode, 'mbox-error');
that._mbox.show("Failed to log in!", "No username supplied.");
return;
}

this.set('isAlreadyLoggingIn', true);
this._standBy.show();

Expand Down