feat: New change password page with server capabilities check

This commit is contained in:
krille-chan 2023-12-23 09:48:35 +01:00
commit 5847fe0546
No known key found for this signature in database
7 changed files with 296 additions and 94 deletions

View file

@ -9,10 +9,16 @@ import 'package:matrix/matrix.dart';
import 'uia_request_manager.dart';
extension LocalizedExceptionExtension on Object {
String toLocalizedString(BuildContext context) {
String toLocalizedString(
BuildContext context, [
ExceptionContext? exceptionContext,
]) {
if (this is MatrixException) {
switch ((this as MatrixException).error) {
case MatrixError.M_FORBIDDEN:
if (exceptionContext == ExceptionContext.changePassword) {
return L10n.of(context)!.passwordIsWrong;
}
return L10n.of(context)!.noPermission;
case MatrixError.M_LIMIT_EXCEEDED:
return L10n.of(context)!.tooManyRequestsWarning;
@ -70,3 +76,7 @@ extension LocalizedExceptionExtension on Object {
return L10n.of(context)!.oopsSomethingWentWrong;
}
}
enum ExceptionContext {
changePassword,
}