migration-tool: Extract the JWT from the JSON response

The response used to contain just the JWT, but now it's wrapped in JSON.

Fixes #282.
This commit is contained in:
Valentin Tolmer 2022-08-03 21:28:45 +02:00 committed by nitnelave
parent 122e08790f
commit 7707367c35
3 changed files with 8 additions and 6 deletions

8
Cargo.lock generated
View File

@ -2936,9 +2936,9 @@ dependencies = [
[[package]] [[package]]
name = "requestty" name = "requestty"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20362058549acfb4b04b014aa182de685d7ded326eaf092db11030431c92693a" checksum = "8d06fb394ca73d15ad0c7bbc673459506a851a84586cd90d67d42932a280281e"
dependencies = [ dependencies = [
"requestty-ui", "requestty-ui",
"smallvec", "smallvec",
@ -2947,9 +2947,9 @@ dependencies = [
[[package]] [[package]]
name = "requestty-ui" name = "requestty-ui"
version = "0.4.0" version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7b232b5ca049619df09d10909dfe32020bc0d402fd98cb5207fc1d2aa53633e" checksum = "31a4bce6f730d12e36993944036e2f93e88033d8a78734d8734fdb0043662cae"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"crossterm", "crossterm",

View File

@ -7,7 +7,7 @@ authors = ["Valentin Tolmer <valentin@tolmer.fr>"]
[dependencies] [dependencies]
anyhow = "*" anyhow = "*"
rand = "0.8" rand = "0.8"
requestty = "*" requestty = "0.4.1"
serde = "1" serde = "1"
serde_json = "1" serde_json = "1"
smallvec = "*" smallvec = "*"

View File

@ -174,7 +174,9 @@ fn try_login(
response.status().as_str() response.status().as_str()
); );
} }
Ok(response.text()?) let json = serde_json::from_str::<lldap_auth::login::ServerLoginResponse>(&response.text()?)
.context("Could not parse response")?;
Ok(json.token)
} }
pub fn get_lldap_user_and_password( pub fn get_lldap_user_and_password(