Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign out from all devices option when changing password #6262

Merged
merged 13 commits into from
Jun 13, 2022
10 changes: 10 additions & 0 deletions Riot/Assets/en.lproj/Untranslated.strings
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,13 @@
"leave_space_selection_title" = "SELECT ROOMS";
"leave_space_selection_all_rooms" = "Select all rooms";
"leave_space_selection_no_rooms" = "Select no rooms";

// MARK: Password Validation
"password_validation_info_header" = "Your password should meet the criteria below:";
"password_validation_error_header" = "Given password does not meet the criteria below:";
"password_validation_error_min_length" = "At least %d characters.";
"password_validation_error_max_length" = "Not exceed %d characters.";
"password_validation_error_contain_lowercase_letter" = "Contain a lower-case letter.";
"password_validation_error_contain_uppercase_letter" = "Contain an upper-case letter.";
"password_validation_error_contain_number" = "Contain a number.";
"password_validation_error_contain_symbol" = "Contain a symbol.";
8 changes: 4 additions & 4 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ Tap the + to start adding people.";
"settings_add_email_address" = "Add email address";
"settings_phone_number" = "Phone";
"settings_add_phone_number" = "Add phone number";
"settings_change_password" = "Change Matrix account password";
"settings_change_password" = "Change password";
"settings_night_mode" = "Night Mode";
"settings_fail_to_update_profile" = "Fail to update profile";
"settings_three_pids_management_information_part1" = "Manage which email addresses or phone numbers you can use to log in or recover your account here. Control who can find you in ";
Expand Down Expand Up @@ -685,9 +685,9 @@ Tap the + to start adding people.";
"settings_analytics_and_crash_data" = "Send crash and analytics data";
"settings_enable_rageshake" = "Rage shake to report bug";

"settings_old_password" = "old password";
"settings_new_password" = "new password";
"settings_confirm_password" = "confirm password";
"settings_old_password" = "Old password";
"settings_new_password" = "New password";
"settings_confirm_password" = "Confirm password";
"settings_fail_to_update_password" = "Fail to update Matrix account password";
"settings_password_updated" = "Your Matrix account password has been updated";

Expand Down
9 changes: 9 additions & 0 deletions Riot/Categories/MXRestClient+Async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ extension MXRestClient {
resetPassword(parameters: parameters, completion: completion)
}
}

// MARK: - Change Password

/// An async version of `changePassword(from:to:logoutDevices:completion:)`.
func changePassword(from oldPassword: String, to newPassword: String, logoutDevices: Bool) async throws {
try await getResponse { completion in
changePassword(from: oldPassword, to: newPassword, logoutDevices: logoutDevices, completion: completion)
}
}

// MARK: - Private

Expand Down
8 changes: 4 additions & 4 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6495,7 +6495,7 @@ public class VectorL10n: NSObject {
public static func settingsCallsStunServerFallbackDescription(_ p1: String) -> String {
return VectorL10n.tr("Vector", "settings_calls_stun_server_fallback_description", p1)
}
/// Change Matrix account password
/// Change password
public static var settingsChangePassword: String {
return VectorL10n.tr("Vector", "settings_change_password")
}
Expand Down Expand Up @@ -6527,7 +6527,7 @@ public class VectorL10n: NSObject {
public static var settingsConfirmMediaSizeDescription: String {
return VectorL10n.tr("Vector", "settings_confirm_media_size_description")
}
/// confirm password
/// Confirm password
public static var settingsConfirmPassword: String {
return VectorL10n.tr("Vector", "settings_confirm_password")
}
Expand Down Expand Up @@ -6947,7 +6947,7 @@ public class VectorL10n: NSObject {
public static var settingsNewKeyword: String {
return VectorL10n.tr("Vector", "settings_new_keyword")
}
/// new password
/// New password
public static var settingsNewPassword: String {
return VectorL10n.tr("Vector", "settings_new_password")
}
Expand All @@ -6971,7 +6971,7 @@ public class VectorL10n: NSObject {
public static var settingsNotifyMeFor: String {
return VectorL10n.tr("Vector", "settings_notify_me_for")
}
/// old password
/// Old password
public static var settingsOldPassword: String {
return VectorL10n.tr("Vector", "settings_old_password")
}
Expand Down
32 changes: 32 additions & 0 deletions Riot/Generated/UntranslatedStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,38 @@ public extension VectorL10n {
static var leaveSpaceSelectionTitle: String {
return VectorL10n.tr("Untranslated", "leave_space_selection_title")
}
/// Contain a lower-case letter.
static var passwordValidationErrorContainLowercaseLetter: String {
return VectorL10n.tr("Untranslated", "password_validation_error_contain_lowercase_letter")
}
/// Contain a number.
static var passwordValidationErrorContainNumber: String {
return VectorL10n.tr("Untranslated", "password_validation_error_contain_number")
}
/// Contain a symbol.
static var passwordValidationErrorContainSymbol: String {
return VectorL10n.tr("Untranslated", "password_validation_error_contain_symbol")
}
/// Contain an upper-case letter.
static var passwordValidationErrorContainUppercaseLetter: String {
return VectorL10n.tr("Untranslated", "password_validation_error_contain_uppercase_letter")
}
/// Given password does not meet the criteria below:
static var passwordValidationErrorHeader: String {
return VectorL10n.tr("Untranslated", "password_validation_error_header")
}
/// Not exceed %d characters.
static func passwordValidationErrorMaxLength(_ p1: Int) -> String {
return VectorL10n.tr("Untranslated", "password_validation_error_max_length", p1)
}
/// At least %d characters.
static func passwordValidationErrorMinLength(_ p1: Int) -> String {
return VectorL10n.tr("Untranslated", "password_validation_error_min_length", p1)
}
/// Your password should meet the criteria below:
static var passwordValidationInfoHeader: String {
return VectorL10n.tr("Untranslated", "password_validation_info_header")
}
/// This feature isn't available here. For now, you can do this with %@ on your computer.
static func spacesFeatureNotAvailable(_ p1: String) -> String {
return VectorL10n.tr("Untranslated", "spaces_feature_not_available", p1)
Expand Down
8 changes: 6 additions & 2 deletions Riot/Modules/MatrixKit/Models/Account/MXKAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,15 @@ typedef BOOL (^MXKAccountOnCertificateChange)(MXKAccount *mxAccount, NSData *cer

@param oldPassword the old password.
@param newPassword the new password.

@param logoutDevices flag to logout from all devices.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
*/
- (void)changePassword:(NSString*)oldPassword with:(NSString*)newPassword success:(void (^)(void))success failure:(void (^)(NSError *error))failure;
- (void)changePassword:(NSString*)oldPassword
with:(NSString*)newPassword
logoutDevices:(BOOL)logoutDevices
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure;

/**
Load the 3PIDs linked to this account.
Expand Down
3 changes: 2 additions & 1 deletion Riot/Modules/MatrixKit/Models/Account/MXKAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,13 @@ - (void)setUserAvatarUrl:(NSString*)avatarUrl success:(void (^)(void))success fa
}
}

- (void)changePassword:(NSString*)oldPassword with:(NSString*)newPassword success:(void (^)(void))success failure:(void (^)(NSError *error))failure
- (void)changePassword:(NSString*)oldPassword with:(NSString*)newPassword logoutDevices:(BOOL)logoutDevices success:(void (^)(void))success failure:(void (^)(NSError *error))failure
{
if (mxSession)
{
[mxRestClient changePassword:oldPassword
with:newPassword
logoutDevices:logoutDevices
success:^{

if (success) {
Expand Down
Loading