Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Handle device_id returned from the fallback login page #520

Merged
merged 4 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Changes in MatrixKit in 0.9.6 (2019-02-)
==========================================

Improvements:
* Upgrade MatrixSDK version ([v0.12.3](https://github.com/matrix-org/matrix-ios-sdk/releases/tag/v0.12.3)).

Bug fix:
* Handle device_id returned from the fallback login page (vector-im/riot-ios/issues/2301).

Changes in MatrixKit in 0.9.5 (2019-02-15)
==========================================

Expand Down
19 changes: 8 additions & 11 deletions MatrixKit/Views/Authentication/MXKAuthenticationFallbackWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,21 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
if ([@"onRegistered" isEqualToString:parameters[@"action"]])
{
// Translate the JS registration event to MXCredentials
// We cannot use [MXCredentials modelFromJSON:] because of https://github.com/matrix-org/synapse/issues/4756
// Because of this issue, we cannot get the device_id allocated by the homeserver
// TODO: Fix it once the homeserver issue is fixed (filed at https://github.com/vector-im/riot-meta/issues/273).
MXCredentials *credentials = [[MXCredentials alloc] initWithHomeServer:parameters[@"homeServer"] userId:parameters[@"userId"] accessToken:parameters[@"accessToken"]];

// And inform the client
onSuccess(credentials);
}
else if ([@"onLogin" isEqualToString:parameters[@"action"]])
{
// Translate the JS login event to MXCredentials
NSString *homeServer = parameters[@"response"][@"home_server"];
NSString *userId = parameters[@"response"][@"user_id"];
NSString *accessToken = parameters[@"response"][@"access_token"];

// Sanity check
if (homeServer.length && userId.length && accessToken.length)
{
MXCredentials *credentials = [[MXCredentials alloc] initWithHomeServer:homeServer userId:userId accessToken:accessToken];
// And inform the client
onSuccess(credentials);
}
MXCredentials *credentials = [MXCredentials modelFromJSON:parameters[@"response"]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If parameters[@"response"] is nil an empty MXCredentials will be created. We could maybe add a failure closure to this method - (void)openFallbackPage:(NSString*)fallbackPage success:(void (^)(MXCredentials *credentials))success;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a PR for a fix for device_id not a PR for a behavior change.


// And inform the client
onSuccess(credentials);
}
}
return NO;
Expand Down