mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-01 09:00:04 +01:00
Merge pull request #84 from mashedcode/nit-weird-return-value-required
imp(flows) don't require present_user_url to return an additional char
This commit is contained in:
@@ -142,7 +142,11 @@ pub trait AuthenticatorDelegate {
|
||||
url);
|
||||
|
||||
let mut code = String::new();
|
||||
io::stdin().read_line(&mut code).ok().map(|_| code)
|
||||
io::stdin().read_line(&mut code).ok().map(|_| {
|
||||
// Remove newline
|
||||
code.pop();
|
||||
code
|
||||
})
|
||||
} else {
|
||||
println!("Please direct your browser to {} and follow the instructions displayed \
|
||||
there.",
|
||||
|
||||
@@ -181,9 +181,14 @@ impl<C> InstalledFlow<C>
|
||||
Result::Err(Box::new(io::Error::new(io::ErrorKind::UnexpectedEof,
|
||||
"couldn't read code")))
|
||||
}
|
||||
// Remove newline
|
||||
Some(mut code) => {
|
||||
code.pop();
|
||||
// Partial backwards compatibilty in case an implementation adds a new line
|
||||
// due to previous behaviour.
|
||||
let ends_with_newline =
|
||||
code.chars().last().map(|c| c == '\n').unwrap_or(false);
|
||||
if ends_with_newline {
|
||||
code.pop();
|
||||
}
|
||||
Result::Ok(code)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user