Skip to content

Commit

Permalink
Merge pull request #496 from waterkip/gh-477-logout_should_not_requir…
Browse files Browse the repository at this point in the history
…e_a_login

Fix bug where logout requires login by @waterkip
  • Loading branch information
GPaulovics authored Apr 5, 2019
2 parents 81ed15c + 0bb0f29 commit b838abc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions cmd-logout.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ int cmd_logout(int argc, char **argv)
if (optind < argc)
die_usage(cmd_logout_usage);

if (!config_exists("verify"))
die("Not currently logged in.");

if (!force && !ask_yes_no(true, "Are you sure you would like to log out?")) {
terminal_printf(TERMINAL_FG_YELLOW TERMINAL_BOLD "Log out" TERMINAL_RESET ": aborted.\n");
return 1;
}

init_all(0, key, &session, NULL);
if (agent_ask(key)) {
init_all(0, key, &session, NULL);
lastpass_logout(session);
}

session_kill();
lastpass_logout(session);

terminal_printf(TERMINAL_FG_YELLOW TERMINAL_BOLD "Log out" TERMINAL_RESET ": complete.\n");
return 0;
}
7 changes: 5 additions & 2 deletions session.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ struct session *session_load(unsigned const char key[KDF_HASH_LEN])

void session_kill()
{
if (!config_unlink("verify") || !config_unlink("username") || !config_unlink("session_sessionid") || !config_unlink("iterations"))
die_errno("could not log out.");
config_unlink("verify");
config_unlink("username");
config_unlink("session_sessionid");
config_unlink("iterations");

config_unlink("blob");
config_unlink("session_token");
config_unlink("session_uid");
Expand Down

0 comments on commit b838abc

Please sign in to comment.