From 3e860feb133f278dceb354160e035f5c381b9351 Mon Sep 17 00:00:00 2001 From: MinhPhan8803 <82825427+MinhPhan8803@users.noreply.github.com> Date: Mon, 17 Apr 2023 19:19:52 -0500 Subject: [PATCH] AuthSession non empty vec part 2 (#1543) --- server/lib/src/idm/authsession.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/lib/src/idm/authsession.rs b/server/lib/src/idm/authsession.rs index caef0aa9a..3580f5eea 100644 --- a/server/lib/src/idm/authsession.rs +++ b/server/lib/src/idm/authsession.rs @@ -698,7 +698,7 @@ impl CredHandler { /// "InProgress", "Success" or "Denied". From there the CredHandler /// is interacted with until we move to either "Success" or "Denied". enum AuthSessionState { - Init(Vec), + Init(NonEmpty), // Stop! Don't make this a vec - make the credhandler able to hold multiple // internal copies of it's type and check against them all. // @@ -757,7 +757,7 @@ impl AuthSession { // based on the anonymous ... in theory this could be cleaner // and interact with the account more? if account.is_anonymous() { - AuthSessionState::Init(vec![CredHandler::Anonymous { + AuthSessionState::Init(nonempty![CredHandler::Anonymous { cred_id: account.uuid, }]) } else { @@ -780,11 +780,11 @@ impl AuthSession { handlers.push(ch); }; - if handlers.is_empty() { + if let Some(non_empty_handlers) = NonEmpty::collect(handlers.into_iter()) { + AuthSessionState::Init(non_empty_handlers) + } else { security_info!("account has no available credentials"); AuthSessionState::Denied("invalid credential state") - } else { - AuthSessionState::Init(handlers) } } } else {