Skip to content

Commit

Permalink
Hook up password storing for Linux client
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed Apr 4, 2023
1 parent d2c7264 commit e1e38b0
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions Sources/Plasma/Apps/plClient/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ You can contact Cyan Worlds, Inc. by email [email protected]
#include "plStatusLog/plStatusLog.h"

#include "pfConsoleCore/pfConsoleEngine.h"
#include "pfPasswordStore/pfPasswordStore.h"

extern bool gDataServerLocal;
extern bool gSkipPreload;
Expand Down Expand Up @@ -276,16 +277,42 @@ static bool ConsoleLoginScreen()
fflush(stdout);

char username[kMaxAccountNameLength];
char password[kMaxPasswordLength];

if (fscanf(stdin, "%s", username) != 1) {
return false;
}

fprintf(stdout, "Password: ");
fflush(stdout);
pfPasswordStore* store = pfPasswordStore::Instance();
ST::string password = store->GetPassword(username);

if (!password.empty()) {
fprintf(stdout, "Use saved password? [y/n] ");
fflush(stdout);
char c;
fscanf(stdin, " %c", &c);
if (c == 'n' || c == 'N') {
password = ST_LITERAL("");
}
fprintf(stdout, "\n");
}

getpassword(password);
if (password.empty()) {
fprintf(stdout, "Password: ");
fflush(stdout);

char tmpPassword[kMaxPasswordLength];
getpassword(tmpPassword);
password = tmpPassword;

fprintf(stdout, "Save password? [y/n] ");
fflush(stdout);
char c;
fscanf(stdin, " %c", &c);
if (c == 'y' || c == 'Y') {
store->SetPassword(username, password);
}
fprintf(stdout, "\n");
}

ShaDigest namePassHash;
CalculateHash(username, password, namePassHash);
Expand Down

0 comments on commit e1e38b0

Please sign in to comment.