Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Unified Diff: examples/bank_app/customer.cc

Issue 1418013004: Principal Service: Add support for multiple user accounts (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: examples/bank_app/customer.cc
diff --git a/examples/bank_app/customer.cc b/examples/bank_app/customer.cc
index 7fb227f2d8b4c104198e6bcbfb5851da3afaf8bf..4f49907600685985bfbf499b298df0a26614d803 100644
--- a/examples/bank_app/customer.cc
+++ b/examples/bank_app/customer.cc
@@ -15,17 +15,9 @@ namespace examples {
class LoginHandler {
public:
- void Run(const vanadium::BlessingPtr& b) const {
- std::string user;
- if (b && b->chain.size() > 0) {
- user = b->chain[0]->extension;
- for (size_t i = 1; i < b->chain.size(); i++) {
- user += vanadium::ChainSeparator;
- user += b->chain[i]->extension;
- }
- }
- if (!user.empty()) {
- MOJO_LOG(INFO) << "Welcome: " << user;
+ void Run(const vanadium::UserPtr& user) const {
+ if (user) {
+ MOJO_LOG(INFO) << "User logged-in as " << user->email;
}
}
};
@@ -33,13 +25,15 @@ class LoginHandler {
class BankCustomer : public mojo::ApplicationDelegate {
public:
void Initialize(mojo::ApplicationImpl* app) override {
- // Get user login credentials
app->ConnectToService("mojo:principal_service", &login_service_);
+
+ // Login to the principal service to get a user identity.
login_service_->Login(LoginHandler());
- // Check and see whether we got a valid user blessing.
+ // Check and see whether we got a valid user id.
if (!login_service_.WaitForIncomingResponse()) {
MOJO_LOG(INFO) << "Login() to the principal service failed\n";
ashankar 2015/10/30 02:24:13 Remove trailing "\n", shouldn't be necessary with
ataly 2015/11/04 00:24:29 Done.
}
+
BankPtr bank;
app->ConnectToService("mojo:bank", &bank);
bank->Deposit(500/*usd*/);

Powered by Google App Engine
This is Rietveld 408576698