Skip to content

Commit 232c23e

Browse files
fl0llipoljar
authored andcommitted
feat(ffi): allow setting existing device id for Client.url_for_oidc
Signed-off-by: fl0lli <github@fl0lli.de>
1 parent 7d9d5bf commit 232c23e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ use ruma::{
7878
RoomAccountDataEvent as RumaRoomAccountDataEvent,
7979
},
8080
push::{HttpPusherData as RumaHttpPusherData, PushFormat as RumaPushFormat},
81-
OwnedServerName, RoomAliasId, RoomOrAliasId, ServerName,
81+
OwnedDeviceId, OwnedServerName, RoomAliasId, RoomOrAliasId, ServerName,
8282
};
8383
use serde::{Deserialize, Serialize};
8484
use serde_json::{json, Value};
@@ -457,16 +457,25 @@ impl Client {
457457
/// However, it should be noted that when providing a user ID as a hint
458458
/// for MAS (with no upstream provider), then the format to use is defined
459459
/// by [MSC4198]: https://github.com/matrix-org/matrix-spec-proposals/pull/4198
460+
///
461+
/// * `device_id` - The unique ID that will be associated with the session.
462+
/// If not set, a random one will be generated. It can be an existing
463+
/// device ID from a previous login call. Note that this should be done
464+
/// only if the client also holds the corresponding encryption keys.
460465
pub async fn url_for_oidc(
461466
&self,
462467
oidc_configuration: &OidcConfiguration,
463468
prompt: Option<OidcPrompt>,
464469
login_hint: Option<String>,
470+
device_id: Option<String>,
465471
) -> Result<Arc<OAuthAuthorizationData>, OidcError> {
466472
let registration_data = oidc_configuration.registration_data()?;
467473
let redirect_uri = oidc_configuration.redirect_uri()?;
468474

469-
let mut url_builder = self.inner.oauth().login(redirect_uri, None, Some(registration_data));
475+
let device_id = device_id.map(|id| OwnedDeviceId::from(id));
476+
477+
let mut url_builder =
478+
self.inner.oauth().login(redirect_uri, device_id, Some(registration_data));
470479

471480
if let Some(prompt) = prompt {
472481
url_builder = url_builder.prompt(vec![prompt.into()]);

0 commit comments

Comments
 (0)