@@ -6,7 +6,6 @@ mod output;
66use output:: { Output , OutputResult , Status } ;
77
88use anyhow:: { Context , Result } ;
9- use clap:: { Error , ErrorKind } ;
109use serde:: Serialize ;
1110use std:: collections:: HashMap ;
1211use std:: env;
@@ -286,6 +285,7 @@ fn run() -> Result<()> {
286285 if let Some ( matches) = matches. subcommand_matches ( "login" ) {
287286 let email = matches. value_of ( "email" ) ;
288287 let set_access_token = matches. value_of ( "set-access-token" ) ;
288+ let base64 = matches. is_present ( "base64" ) ;
289289
290290 // get token from argument or server
291291 let token = if let Some ( token) = set_access_token {
@@ -299,7 +299,14 @@ fn run() -> Result<()> {
299299 } else if let Some ( email) = email {
300300 // TODO: "Please enter password" and quiet param
301301 let password = rpassword:: read_password ( ) . context ( "Failed to read password" ) ?;
302- core. authenticate ( client_name, email. to_string ( ) , password)
302+ let decoded = if base64 {
303+ let bytes = base64:: decode ( password) . context ( "Password was invalid base64" ) ?;
304+ String :: from_utf8 ( bytes)
305+ . context ( "Base64 password decoded into invalid UTF-8" ) ?
306+ } else {
307+ password
308+ } ;
309+ core. authenticate ( client_name, email. to_string ( ) , decoded)
303310 . context ( "Failed to authenticate with TMC" ) ?
304311 } else {
305312 unreachable ! ( "validation error" ) ;
0 commit comments