mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-24 14:32:37 +01:00
fix: Reset password
This commit is contained in:
parent
7be11e326e
commit
3ca31fb3d2
@ -153,19 +153,22 @@ class LoginController extends State<Login> {
|
|||||||
final input = await showTextInputDialog(
|
final input = await showTextInputDialog(
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
context: context,
|
context: context,
|
||||||
title: L10n.of(context)!.enterAnEmailAddress,
|
title: L10n.of(context)!.passwordForgotten,
|
||||||
|
message: L10n.of(context)!.enterAnEmailAddress,
|
||||||
okLabel: L10n.of(context)!.ok,
|
okLabel: L10n.of(context)!.ok,
|
||||||
cancelLabel: L10n.of(context)!.cancel,
|
cancelLabel: L10n.of(context)!.cancel,
|
||||||
|
fullyCapitalizedForMaterial: false,
|
||||||
textFields: [
|
textFields: [
|
||||||
DialogTextField(
|
DialogTextField(
|
||||||
|
initialText:
|
||||||
|
usernameController.text.isEmail ? usernameController.text : '',
|
||||||
hintText: L10n.of(context)!.enterAnEmailAddress,
|
hintText: L10n.of(context)!.enterAnEmailAddress,
|
||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (input == null) return;
|
if (input == null) return;
|
||||||
final clientSecret =
|
final clientSecret = DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
Matrix.of(context).client.generateUniqueTransactionId();
|
|
||||||
final response = await showFutureLoadingDialog(
|
final response = await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () =>
|
future: () =>
|
||||||
@ -182,14 +185,17 @@ class LoginController extends State<Login> {
|
|||||||
title: L10n.of(context)!.weSentYouAnEmail,
|
title: L10n.of(context)!.weSentYouAnEmail,
|
||||||
message: L10n.of(context)!.pleaseClickOnLink,
|
message: L10n.of(context)!.pleaseClickOnLink,
|
||||||
okLabel: L10n.of(context)!.iHaveClickedOnLink,
|
okLabel: L10n.of(context)!.iHaveClickedOnLink,
|
||||||
|
fullyCapitalizedForMaterial: false,
|
||||||
);
|
);
|
||||||
if (ok != OkCancelResult.ok) return;
|
if (ok != OkCancelResult.ok) return;
|
||||||
final password = await showTextInputDialog(
|
final password = await showTextInputDialog(
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
context: context,
|
context: context,
|
||||||
title: L10n.of(context)!.chooseAStrongPassword,
|
title: L10n.of(context)!.passwordForgotten,
|
||||||
|
message: L10n.of(context)!.chooseAStrongPassword,
|
||||||
okLabel: L10n.of(context)!.ok,
|
okLabel: L10n.of(context)!.ok,
|
||||||
cancelLabel: L10n.of(context)!.cancel,
|
cancelLabel: L10n.of(context)!.cancel,
|
||||||
|
fullyCapitalizedForMaterial: false,
|
||||||
textFields: [
|
textFields: [
|
||||||
const DialogTextField(
|
const DialogTextField(
|
||||||
hintText: '******',
|
hintText: '******',
|
||||||
@ -200,17 +206,22 @@ class LoginController extends State<Login> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (password == null) return;
|
if (password == null) return;
|
||||||
|
final data = <String, dynamic>{
|
||||||
|
'new_password': password.single,
|
||||||
|
"auth": AuthenticationThreePidCreds(
|
||||||
|
type: AuthenticationTypes.emailIdentity,
|
||||||
|
threepidCreds: ThreepidCreds(
|
||||||
|
sid: response.result!.sid,
|
||||||
|
clientSecret: clientSecret,
|
||||||
|
),
|
||||||
|
).toJson(),
|
||||||
|
};
|
||||||
final success = await showFutureLoadingDialog(
|
final success = await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () => Matrix.of(context).getLoginClient().changePassword(
|
future: () => Matrix.of(context).getLoginClient().request(
|
||||||
password.single,
|
RequestType.POST,
|
||||||
auth: AuthenticationThreePidCreds(
|
'/client/r0/account/password',
|
||||||
type: AuthenticationTypes.emailIdentity,
|
data: data,
|
||||||
threepidCreds: ThreepidCreds(
|
|
||||||
sid: response.result!.sid,
|
|
||||||
clientSecret: clientSecret,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (success.error == null) {
|
if (success.error == null) {
|
||||||
|
@ -88,16 +88,18 @@ class LoginView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Center(
|
const Divider(height: 32),
|
||||||
child: TextButton(
|
Padding(
|
||||||
onPressed: controller.passwordForgotten,
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
child: Text(
|
child: ElevatedButton(
|
||||||
L10n.of(context)!.passwordForgotten,
|
onPressed: controller.loading
|
||||||
style: const TextStyle(
|
? null
|
||||||
color: Colors.blue,
|
: controller.passwordForgotten,
|
||||||
decoration: TextDecoration.underline,
|
style: ElevatedButton.styleFrom(
|
||||||
),
|
primary: Theme.of(context).secondaryHeaderColor,
|
||||||
|
onPrimary: Colors.red,
|
||||||
),
|
),
|
||||||
|
child: Text(L10n.of(context)!.passwordForgotten),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -960,7 +960,7 @@ packages:
|
|||||||
name: matrix
|
name: matrix
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.8.10"
|
version: "0.8.11"
|
||||||
matrix_api_lite:
|
matrix_api_lite:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -57,7 +57,7 @@ dependencies:
|
|||||||
intl: any
|
intl: any
|
||||||
localstorage: ^4.0.0+1
|
localstorage: ^4.0.0+1
|
||||||
lottie: ^1.2.2
|
lottie: ^1.2.2
|
||||||
matrix: ^0.8.10
|
matrix: ^0.8.11
|
||||||
matrix_link_text: ^1.0.2
|
matrix_link_text: ^1.0.2
|
||||||
open_noti_settings: ^0.4.0
|
open_noti_settings: ^0.4.0
|
||||||
package_info_plus: ^1.3.0
|
package_info_plus: ^1.3.0
|
||||||
|
Loading…
Reference in New Issue
Block a user