clippy 📎
This commit is contained in:
@@ -187,13 +187,14 @@ impl AuthorizationGrant {
|
||||
self.created_at - max_age
|
||||
}
|
||||
|
||||
pub fn parse_login_hint(&self, homeserver: BoxHomeserverConnection) -> LoginHint {
|
||||
#[must_use]
|
||||
pub fn parse_login_hint(&self, homeserver: &BoxHomeserverConnection) -> LoginHint {
|
||||
let Some(login_hint) = &self.login_hint else {
|
||||
return LoginHint::None;
|
||||
};
|
||||
|
||||
// Return none if the format is incorrect
|
||||
let Some((prefix, value)) = login_hint.split_once(":") else {
|
||||
let Some((prefix, value)) = login_hint.split_once(':') else {
|
||||
return LoginHint::None;
|
||||
};
|
||||
|
||||
@@ -304,7 +305,7 @@ mod tests {
|
||||
..AuthorizationGrant::sample(Utc::now(), &mut rng)
|
||||
};
|
||||
|
||||
let hint = grant.parse_login_hint(get_homeserver());
|
||||
let hint = grant.parse_login_hint(&get_homeserver());
|
||||
|
||||
assert!(matches!(hint, LoginHint::None));
|
||||
}
|
||||
@@ -319,7 +320,7 @@ mod tests {
|
||||
..AuthorizationGrant::sample(Utc::now(), &mut rng)
|
||||
};
|
||||
|
||||
let hint = grant.parse_login_hint(get_homeserver());
|
||||
let hint = grant.parse_login_hint(&get_homeserver());
|
||||
|
||||
assert!(matches!(hint, LoginHint::MXID(mxid) if mxid.localpart() == "example-user"));
|
||||
}
|
||||
@@ -334,7 +335,7 @@ mod tests {
|
||||
..AuthorizationGrant::sample(Utc::now(), &mut rng)
|
||||
};
|
||||
|
||||
let hint = grant.parse_login_hint(get_homeserver());
|
||||
let hint = grant.parse_login_hint(&get_homeserver());
|
||||
|
||||
assert!(matches!(hint, LoginHint::None));
|
||||
}
|
||||
@@ -349,7 +350,7 @@ mod tests {
|
||||
..AuthorizationGrant::sample(Utc::now(), &mut rng)
|
||||
};
|
||||
|
||||
let hint = grant.parse_login_hint(get_homeserver());
|
||||
let hint = grant.parse_login_hint(&get_homeserver());
|
||||
|
||||
assert!(matches!(hint, LoginHint::None));
|
||||
}
|
||||
@@ -364,7 +365,7 @@ mod tests {
|
||||
..AuthorizationGrant::sample(Utc::now(), &mut rng)
|
||||
};
|
||||
|
||||
let hint = grant.parse_login_hint(get_homeserver());
|
||||
let hint = grant.parse_login_hint(&get_homeserver());
|
||||
|
||||
assert!(matches!(hint, LoginHint::None));
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ async fn login(
|
||||
fn handle_login_hint(
|
||||
ctx: &mut LoginContext,
|
||||
next: &PostAuthContext,
|
||||
homeserver: BoxHomeserverConnection,
|
||||
homeserver: &BoxHomeserverConnection,
|
||||
) {
|
||||
let form_state = ctx.form_state_mut();
|
||||
|
||||
@@ -307,7 +307,7 @@ fn handle_login_hint(
|
||||
|
||||
if let PostAuthContextInner::ContinueAuthorizationGrant { ref grant } = next.ctx {
|
||||
let value = match grant.parse_login_hint(homeserver) {
|
||||
LoginHint::MXID(mxid) => Some(mxid.localpart().to_string()),
|
||||
LoginHint::MXID(mxid) => Some(mxid.localpart().to_owned()),
|
||||
LoginHint::None => None,
|
||||
};
|
||||
form_state.set_value(LoginFormField::Username, value);
|
||||
@@ -325,7 +325,7 @@ async fn render(
|
||||
) -> Result<String, FancyError> {
|
||||
let next = action.load_context(repo).await?;
|
||||
let ctx = if let Some(next) = next {
|
||||
handle_login_hint(&mut ctx, &next, homeserver);
|
||||
handle_login_hint(&mut ctx, &next, &homeserver);
|
||||
|
||||
ctx.with_post_action(next)
|
||||
} else {
|
||||
|
||||
@@ -175,8 +175,7 @@ impl<K: FormField> FormState<K> {
|
||||
pub fn has_value(&self, field: K) -> bool {
|
||||
self.fields
|
||||
.get(&field)
|
||||
.map(|f| f.value.is_some())
|
||||
.unwrap_or(false)
|
||||
.is_some_and(|f| f.value.is_some())
|
||||
}
|
||||
|
||||
/// Returns `true` if the form has no error attached to it
|
||||
|
||||
Reference in New Issue
Block a user