Skip to content

Commit c5cca60

Browse files
committed
Hook up password storing for Linux client
1 parent d391e66 commit c5cca60

File tree

1 file changed

+31
-4
lines changed
  • Sources/Plasma/Apps/plClient/linux

1 file changed

+31
-4
lines changed

Sources/Plasma/Apps/plClient/linux/main.cpp

+31-4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ You can contact Cyan Worlds, Inc. by email [email protected]
7777
#include "plStatusLog/plStatusLog.h"
7878

7979
#include "pfConsoleCore/pfConsoleEngine.h"
80+
#include "pfPasswordStore/pfPasswordStore.h"
8081

8182
extern bool gDataServerLocal;
8283
extern bool gSkipPreload;
@@ -276,16 +277,42 @@ static bool ConsoleLoginScreen()
276277
fflush(stdout);
277278

278279
char username[kMaxAccountNameLength];
279-
char password[kMaxPasswordLength];
280280

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

285-
fprintf(stdout, "Password: ");
286-
fflush(stdout);
285+
pfPasswordStore* store = pfPasswordStore::Instance();
286+
ST::string password = store->GetPassword(username);
287+
288+
if (!password.empty()) {
289+
fprintf(stdout, "Use saved password? [y/n] ");
290+
fflush(stdout);
291+
char c;
292+
fscanf(stdin, " %c", &c);
293+
if (c == 'n' || c == 'N') {
294+
password = ST_LITERAL("");
295+
}
296+
fprintf(stdout, "\n");
297+
}
287298

288-
getpassword(password);
299+
if (password.empty()) {
300+
fprintf(stdout, "Password: ");
301+
fflush(stdout);
302+
303+
char tmpPassword[kMaxPasswordLength];
304+
getpassword(tmpPassword);
305+
password = tmpPassword;
306+
307+
fprintf(stdout, "Save password? [y/n] ");
308+
fflush(stdout);
309+
char c;
310+
fscanf(stdin, " %c", &c);
311+
if (c == 'y' || c == 'Y') {
312+
store->SetPassword(username, password);
313+
}
314+
fprintf(stdout, "\n");
315+
}
289316

290317
ShaDigest namePassHash;
291318
CalculateHash(username, password, namePassHash);

0 commit comments

Comments
 (0)