|
77 | 77 | #include "plStatusLog/plStatusLog.h"
|
78 | 78 |
|
79 | 79 | #include "pfConsoleCore/pfConsoleEngine.h"
|
| 80 | +#include "pfPasswordStore/pfPasswordStore.h" |
80 | 81 |
|
81 | 82 | extern bool gDataServerLocal;
|
82 | 83 | extern bool gSkipPreload;
|
@@ -276,16 +277,42 @@ static bool ConsoleLoginScreen()
|
276 | 277 | fflush(stdout);
|
277 | 278 |
|
278 | 279 | char username[kMaxAccountNameLength];
|
279 |
| - char password[kMaxPasswordLength]; |
280 | 280 |
|
281 | 281 | if (fscanf(stdin, "%s", username) != 1) {
|
282 | 282 | return false;
|
283 | 283 | }
|
284 | 284 |
|
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 | + } |
287 | 298 |
|
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 | + } |
289 | 316 |
|
290 | 317 | ShaDigest namePassHash;
|
291 | 318 | CalculateHash(username, password, namePassHash);
|
|
0 commit comments