Skip to content

Commit 6920cc6

Browse files
committed
Hook up password storing for Linux client
1 parent 8d426a5 commit 6920cc6

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;
@@ -275,16 +276,42 @@ static bool ConsoleLoginScreen()
275276
fflush(stdout);
276277

277278
char username[kMaxAccountNameLength];
278-
char password[kMaxPasswordLength];
279279

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

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

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

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

0 commit comments

Comments
 (0)