Generating browser link on signer new-token
This commit is contained in:
parent
d5d1c1b674
commit
aa147461b0
@ -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)
|
||||
|
@ -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<String, String> {
|
||||
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<String> {
|
||||
|
Loading…
Reference in New Issue
Block a user