mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
service-account or person validity show returns for non-existing identity (#2258)
Fixes #2152
This commit is contained in:
parent
208d7c9932
commit
18b4b7549f
|
@ -352,30 +352,29 @@ impl PersonOpt {
|
||||||
AccountValidity::Show(ano) => {
|
AccountValidity::Show(ano) => {
|
||||||
let client = ano.copt.to_client(OpType::Read).await;
|
let client = ano.copt.to_client(OpType::Read).await;
|
||||||
|
|
||||||
|
let entry = match client
|
||||||
|
.idm_person_account_get(ano.aopts.account_id.as_str())
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Err(err) => {
|
||||||
|
error!(
|
||||||
|
"No account {} found, or other error occurred: {:?}",
|
||||||
|
ano.aopts.account_id.as_str(),
|
||||||
|
err
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Ok(val) => match val {
|
||||||
|
Some(val) => val,
|
||||||
|
None => {
|
||||||
|
error!("No account {} found!", ano.aopts.account_id.as_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
println!("user: {}", ano.aopts.account_id.as_str());
|
println!("user: {}", ano.aopts.account_id.as_str());
|
||||||
let ex = match client
|
if let Some(t) = entry.attrs.get(ATTR_ACCOUNT_VALID_FROM) {
|
||||||
.idm_person_account_get_attr(
|
|
||||||
ano.aopts.account_id.as_str(),
|
|
||||||
ATTR_ACCOUNT_EXPIRE,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(v) => v,
|
|
||||||
Err(e) => return handle_client_error(e, &ano.copt.output_mode),
|
|
||||||
};
|
|
||||||
|
|
||||||
let vf = match client
|
|
||||||
.idm_person_account_get_attr(
|
|
||||||
ano.aopts.account_id.as_str(),
|
|
||||||
ATTR_ACCOUNT_VALID_FROM,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(v) => v,
|
|
||||||
Err(e) => return handle_client_error(e, &ano.copt.output_mode),
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(t) = vf {
|
|
||||||
// Convert the time to local timezone.
|
// Convert the time to local timezone.
|
||||||
let t = OffsetDateTime::parse(&t[0], &Rfc3339)
|
let t = OffsetDateTime::parse(&t[0], &Rfc3339)
|
||||||
.map(|odt| {
|
.map(|odt| {
|
||||||
|
@ -393,7 +392,7 @@ impl PersonOpt {
|
||||||
println!("valid after: any time");
|
println!("valid after: any time");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(t) = ex {
|
if let Some(t) = entry.attrs.get(ATTR_ACCOUNT_EXPIRE) {
|
||||||
let t = OffsetDateTime::parse(&t[0], &Rfc3339)
|
let t = OffsetDateTime::parse(&t[0], &Rfc3339)
|
||||||
.map(|odt| {
|
.map(|odt| {
|
||||||
odt.to_offset(
|
odt.to_offset(
|
||||||
|
|
|
@ -365,36 +365,29 @@ impl ServiceAccountOpt {
|
||||||
AccountValidity::Show(ano) => {
|
AccountValidity::Show(ano) => {
|
||||||
let client = ano.copt.to_client(OpType::Read).await;
|
let client = ano.copt.to_client(OpType::Read).await;
|
||||||
|
|
||||||
|
let entry = match client
|
||||||
|
.idm_service_account_get(ano.aopts.account_id.as_str())
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Err(err) => {
|
||||||
|
error!(
|
||||||
|
"No account {} found, or other error occurred: {:?}",
|
||||||
|
ano.aopts.account_id.as_str(),
|
||||||
|
err
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Ok(val) => match val {
|
||||||
|
Some(val) => val,
|
||||||
|
None => {
|
||||||
|
error!("No account {} found!", ano.aopts.account_id.as_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
println!("user: {}", ano.aopts.account_id.as_str());
|
println!("user: {}", ano.aopts.account_id.as_str());
|
||||||
let ex = match client
|
if let Some(t) = entry.attrs.get(ATTR_ACCOUNT_VALID_FROM) {
|
||||||
.idm_service_account_get_attr(
|
|
||||||
ano.aopts.account_id.as_str(),
|
|
||||||
ATTR_ACCOUNT_EXPIRE,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(v) => v,
|
|
||||||
Err(e) => {
|
|
||||||
error!("Error -> {:?}", e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let vf = match client
|
|
||||||
.idm_service_account_get_attr(
|
|
||||||
ano.aopts.account_id.as_str(),
|
|
||||||
ATTR_ACCOUNT_VALID_FROM,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(v) => v,
|
|
||||||
Err(e) => {
|
|
||||||
error!("Error -> {:?}", e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(t) = vf {
|
|
||||||
// Convert the time to local timezone.
|
// Convert the time to local timezone.
|
||||||
let t = OffsetDateTime::parse(&t[0], &Rfc3339)
|
let t = OffsetDateTime::parse(&t[0], &Rfc3339)
|
||||||
.map(|odt| {
|
.map(|odt| {
|
||||||
|
@ -412,7 +405,7 @@ impl ServiceAccountOpt {
|
||||||
println!("valid after: any time");
|
println!("valid after: any time");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(t) = ex {
|
if let Some(t) = entry.attrs.get(ATTR_ACCOUNT_EXPIRE) {
|
||||||
let t = OffsetDateTime::parse(&t[0], &Rfc3339)
|
let t = OffsetDateTime::parse(&t[0], &Rfc3339)
|
||||||
.map(|odt| {
|
.map(|odt| {
|
||||||
odt.to_offset(
|
odt.to_offset(
|
||||||
|
|
Loading…
Reference in a new issue