aboutsummaryrefslogtreecommitdiff
path: root/src/common/password.cpp
diff options
context:
space:
mode:
authorLee Clagett <code@leeclagett.com>2017-02-05 17:48:03 -0500
committerLee Clagett <code@leeclagett.com>2017-02-06 01:15:41 -0500
commitce7fcbb4aea884bb4bf433cf419ffa267f859c87 (patch)
treee8fb644b62006d78f801d739fbebad50f2c2409d /src/common/password.cpp
parentMerge pull request #1669 (diff)
downloadmonero-ce7fcbb4aea884bb4bf433cf419ffa267f859c87.tar.xz
Add server auth to monerod, and client auth to wallet-cli and wallet-rpc
Diffstat (limited to '')
-rw-r--r--src/common/password.cpp (renamed from src/wallet/password_container.cpp)27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/wallet/password_container.cpp b/src/common/password.cpp
index 832b93a1a..bdc9c69c0 100644
--- a/src/wallet/password_container.cpp
+++ b/src/common/password.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2016, The Monero Project
+// Copyright (c) 2014-2017, The Monero Project
//
// All rights reserved.
//
@@ -28,7 +28,7 @@
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
-#include "password_container.h"
+#include "password.h"
#include <iostream>
#include <memory.h>
@@ -245,4 +245,27 @@ namespace tools
return boost::none;
}
+
+ boost::optional<login> login::parse(std::string&& userpass, bool verify, const char* message)
+ {
+ login out{};
+ password_container wipe{std::move(userpass)};
+
+ const auto loc = wipe.password().find(':');
+ if (loc == std::string::npos)
+ {
+ auto result = tools::password_container::prompt(verify, message);
+ if (!result)
+ return boost::none;
+
+ out.password = std::move(*result);
+ }
+ else
+ {
+ out.password = password_container{wipe.password().substr(loc + 1)};
+ }
+
+ out.username = wipe.password().substr(0, loc);
+ return {std::move(out)};
+ }
}