refactor: Update sdk
This commit is contained in:
parent
1cc5496849
commit
11c2a8bb26
8 changed files with 58 additions and 75 deletions
|
|
@ -137,16 +137,19 @@ class _LoginState extends State<Login> {
|
|||
],
|
||||
);
|
||||
if (password == null) return;
|
||||
final threepidCreds = {
|
||||
'client_secret': clientSecret,
|
||||
'sid': (response as RequestTokenResponse).sid,
|
||||
};
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.changePassword(password.single, auth: {
|
||||
'type': 'm.login.email.identity',
|
||||
'threepidCreds': threepidCreds, // Don't ask... >.<
|
||||
'threepid_creds': threepidCreds,
|
||||
}),
|
||||
Matrix.of(context).client.changePassword(
|
||||
password.single,
|
||||
auth: AuthenticationThreePidCreds(
|
||||
type: AuthenticationTypes.emailIdentity,
|
||||
threepidCreds: [
|
||||
ThreepidCreds(
|
||||
sid: (response as RequestTokenResponse).sid,
|
||||
clientSecret: clientSecret,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
if (success != false) {
|
||||
FlushbarHelper.createSuccess(
|
||||
|
|
|
|||
|
|
@ -123,11 +123,14 @@ class _SettingsState extends State<Settings> {
|
|||
);
|
||||
if (input == null) return;
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Matrix.of(context).client.deactivateAccount(auth: {
|
||||
'type': 'm.login.password',
|
||||
'user': Matrix.of(context).client.userID,
|
||||
'password': input.single,
|
||||
}),
|
||||
Matrix.of(context).client.deactivateAccount(
|
||||
auth: AuthenticationPassword(
|
||||
password: input.single,
|
||||
user: Matrix.of(context).client.userID,
|
||||
identifier: AuthenticationUserIdentifier(
|
||||
user: Matrix.of(context).client.userID),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,32 +69,13 @@ class _Settings3PidState extends State<Settings3Pid> {
|
|||
);
|
||||
if (password == null) return;
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
Future.microtask(() async {
|
||||
final Function request = ({Map<String, dynamic> auth}) async =>
|
||||
Matrix.of(context).client.addThirdPartyIdentifier(
|
||||
Matrix.of(context).client.uiaRequestBackground(
|
||||
(auth) => Matrix.of(context).client.addThirdPartyIdentifier(
|
||||
clientSecret,
|
||||
(response as RequestTokenResponse).sid,
|
||||
auth: auth,
|
||||
);
|
||||
try {
|
||||
await request();
|
||||
} on MatrixException catch (exception) {
|
||||
if (!exception.requireAdditionalAuthentication) rethrow;
|
||||
await request(
|
||||
auth: {
|
||||
'type': 'm.login.password',
|
||||
'identifier': {
|
||||
'type': 'm.id.user',
|
||||
'user': Matrix.of(context).client.userID,
|
||||
},
|
||||
'user': Matrix.of(context).client.userID,
|
||||
'password': password.single,
|
||||
'session': exception.session,
|
||||
},
|
||||
);
|
||||
}
|
||||
return;
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (success == false) return;
|
||||
setState(() => _request = null);
|
||||
|
|
|
|||
|
|
@ -61,8 +61,15 @@ class DevicesSettingsState extends State<DevicesSettings> {
|
|||
if (password == null) return;
|
||||
|
||||
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
|
||||
matrix.client.deleteDevices(deviceIds,
|
||||
auth: matrix.getAuthByPassword(password.single)));
|
||||
matrix.client.deleteDevices(
|
||||
deviceIds,
|
||||
auth: AuthenticationPassword(
|
||||
password: password.single,
|
||||
user: matrix.client.userID,
|
||||
identifier: AuthenticationUserIdentifier(user: matrix.client.userID),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (success != false) {
|
||||
reload();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
bool loading = false;
|
||||
bool showPassword = true;
|
||||
|
||||
void _signUpAction(BuildContext context, {Map<String, dynamic> auth}) async {
|
||||
void _signUpAction(BuildContext context, {AuthenticationData auth}) async {
|
||||
var matrix = Matrix.of(context);
|
||||
if (passwordController.text.isEmpty) {
|
||||
setState(() => passwordError = L10n.of(context).pleaseEnterYourPassword);
|
||||
|
|
@ -61,10 +61,13 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
true);
|
||||
|
||||
if (currentStage == 'm.login.dummy') {
|
||||
_signUpAction(context, auth: {
|
||||
'type': currentStage,
|
||||
'session': exception.session,
|
||||
});
|
||||
_signUpAction(
|
||||
context,
|
||||
auth: AuthenticationData(
|
||||
type: currentStage,
|
||||
session: exception.session,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
await Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
|
|
@ -72,9 +75,10 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
AuthWebView(
|
||||
currentStage,
|
||||
exception.session,
|
||||
() => _signUpAction(context, auth: {
|
||||
'session': exception.session,
|
||||
}),
|
||||
() => _signUpAction(
|
||||
context,
|
||||
auth: AuthenticationData(session: exception.session),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue