1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Apply password policy on all forms

This commit is contained in:
2021-02-18 18:58:47 +01:00
parent 16ec9a8e00
commit c5d1512375
10 changed files with 135 additions and 50 deletions

View File

@ -4,6 +4,7 @@ import 'package:comunic/helpers/websocket_helper.dart';
import 'package:comunic/models/api_request.dart';
import 'package:comunic/models/authentication_details.dart';
import 'package:comunic/models/new_account.dart';
import 'package:comunic/models/res_check_password_reset_token.dart';
import 'package:shared_preferences/shared_preferences.dart';
/// Account helper
@ -125,6 +126,11 @@ class AccountHelper {
.execWithThrow())
.getObject()["exists"];
/// Get current user email address
static Future<String> getCurrentAccountEmailAddress() async =>
(await APIRequest.withLogin("account/mail")
.execWithThrowGetObject())["mail"];
/// Check out whether security questions have been set for an account or not
///
/// Throws in case of failure
@ -161,10 +167,19 @@ class AccountHelper {
/// Check a password reset token
///
/// Throws in case failure
static Future<void> validatePasswordResetToken(String token) async =>
await APIRequest.withoutLogin("account/check_password_reset_token")
.addString("token", token)
.execWithThrow();
static Future<ResCheckPasswordToken> validatePasswordResetToken(
String token) async {
final response =
await APIRequest.withoutLogin("account/check_password_reset_token")
.addString("token", token)
.execWithThrowGetObject();
return ResCheckPasswordToken(
firstName: response["first_name"],
lastName: response["last_name"],
email: response["mail"],
);
}
/// Change account password using password reset token
///