From aa147461b07cf704df873ec45880e68943e5cda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 11 Nov 2016 17:38:45 +0100 Subject: [PATCH] Generating browser link on signer new-token --- parity/configuration.rs | 4 +++- parity/signer.rs | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/parity/configuration.rs b/parity/configuration.rs index 75d319272..928e9ba7a 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -104,7 +104,9 @@ impl Configuration { Cmd::Version } else if self.args.cmd_signer && self.args.cmd_new_token { Cmd::SignerToken(SignerCommand { - path: dirs.signer + path: dirs.signer, + signer_interface: signer_conf.interface, + signer_port: signer_conf.port, }) } else if self.args.cmd_tools && self.args.cmd_hash { Cmd::Hash(self.args.arg_file) diff --git a/parity/signer.rs b/parity/signer.rs index a26cc431a..fd1258bf6 100644 --- a/parity/signer.rs +++ b/parity/signer.rs @@ -71,12 +71,23 @@ fn codes_path(path: String) -> PathBuf { #[derive(Debug, PartialEq)] pub struct SignerCommand { pub path: String, + pub signer_interface: String, + pub signer_port: u16, } pub fn execute(cmd: SignerCommand) -> Result { - generate_new_token(cmd.path) - .map(|code| format!("This key code will authorise your System Signer UI: {}", Colour::White.bold().paint(code))) - .map_err(|err| format!("Error generating token: {:?}", err)) + let code = try!(generate_new_token(cmd.path).map_err(|err| format!("Error generating token: {:?}", err))); + + let url = format!("http://{}:{}/#/auth?token={}", cmd.signer_interface, cmd.signer_port, code); + Ok(format!( + r#" +Open: {} +to authorize your browser. +Or use the code: {} + "#, + Colour::White.bold().paint(url), + code + )) } pub fn generate_new_token(path: String) -> io::Result {