Skip to content

Commit 1c6a23c

Browse files
committed
cargo fmt
1 parent 88bc11b commit 1c6a23c

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

crates/data-model/src/oauth2/authorization_grant.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ impl AuthorizationGrant {
210210
}
211211

212212
LoginHint::MXID(mxid)
213-
},
213+
}
214214
// Unknown hint type, treat as none
215-
_ => LoginHint::None
215+
_ => LoginHint::None,
216216
}
217217
}
218218

@@ -279,16 +279,16 @@ impl AuthorizationGrant {
279279
response_type_id_token: false,
280280
created_at: now,
281281
requires_consent: false,
282-
login_hint: Some(String::from("mxid:@example-user:example.com"))
282+
login_hint: Some(String::from("mxid:@example-user:example.com")),
283283
}
284284
}
285285
}
286286

287287
#[cfg(test)]
288288
mod tests {
289+
use super::*;
289290
use mas_matrix::MockHomeserverConnection;
290291
use rand::thread_rng;
291-
use super::*;
292292

293293
fn get_homeserver() -> BoxHomeserverConnection {
294294
Box::new(MockHomeserverConnection::new("example.com"))

crates/data-model/src/oauth2/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ mod device_code_grant;
1010
mod session;
1111

1212
pub use self::{
13-
authorization_grant::{AuthorizationCode, AuthorizationGrant, AuthorizationGrantStage, Pkce, LoginHint},
13+
authorization_grant::{
14+
AuthorizationCode, AuthorizationGrant, AuthorizationGrantStage, LoginHint, Pkce,
15+
},
1416
client::{Client, InvalidRedirectUriError, JwksOrJwksUri},
1517
device_code_grant::{DeviceCodeGrant, DeviceCodeGrantState},
1618
session::{Session, SessionState},

crates/handlers/src/views/login.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use mas_axum_utils::{
1515
csrf::{CsrfExt, CsrfToken, ProtectedForm},
1616
FancyError, SessionInfoExt,
1717
};
18-
use mas_data_model::{BrowserSession, UserAgent, oauth2::LoginHint};
18+
use mas_data_model::{oauth2::LoginHint, BrowserSession, UserAgent};
1919
use mas_i18n::DataLocale;
2020
use mas_matrix::BoxHomeserverConnection;
2121
use mas_router::{UpstreamOAuth2Authorize, UrlBuilder};
@@ -25,7 +25,8 @@ use mas_storage::{
2525
BoxClock, BoxRepository, BoxRng, Clock, RepositoryAccess,
2626
};
2727
use mas_templates::{
28-
FieldError, FormError, LoginContext, LoginFormField, PostAuthContext, PostAuthContextInner, TemplateContext, Templates, ToFormState
28+
FieldError, FormError, LoginContext, LoginFormField, PostAuthContext, PostAuthContextInner,
29+
TemplateContext, Templates, ToFormState,
2930
};
3031
use rand::{CryptoRng, Rng};
3132
use serde::{Deserialize, Serialize};
@@ -292,11 +293,17 @@ async fn login(
292293
Ok(user_session)
293294
}
294295

295-
fn handle_login_hint(ctx: &mut LoginContext, next: &PostAuthContext, homeserver: BoxHomeserverConnection) {
296+
fn handle_login_hint(
297+
ctx: &mut LoginContext,
298+
next: &PostAuthContext,
299+
homeserver: BoxHomeserverConnection,
300+
) {
296301
let form_state = ctx.form_state_mut();
297302

298303
// Do not override username if coming from a failed login attempt
299-
if form_state.has_value(LoginFormField::Username) { return; }
304+
if form_state.has_value(LoginFormField::Username) {
305+
return;
306+
}
300307

301308
if let PostAuthContextInner::ContinueAuthorizationGrant { ref grant } = next.ctx {
302309
let value = match grant.parse_login_hint(homeserver) {

crates/templates/src/forms.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ impl<K: FormField> FormState<K> {
173173

174174
/// Checks if a field contains a value
175175
pub fn has_value(&self, field: K) -> bool {
176-
self.fields.get(&field).map(|f| f.value.is_some()).unwrap_or(false)
176+
self.fields
177+
.get(&field)
178+
.map(|f| f.value.is_some())
179+
.unwrap_or(false)
177180
}
178181

179182
/// Returns `true` if the form has no error attached to it

0 commit comments

Comments
 (0)