mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
FIX: Reset password link broken for non-staff user in confirm session dialog (#32765)
This commit is contained in:

committed by
GitHub

parent
672007549b
commit
7820dd2b8f
@ -93,10 +93,7 @@ export default class ConfirmSession extends Component {
|
||||
@action
|
||||
async sendPasswordResetEmail() {
|
||||
try {
|
||||
const result = await ajax("/session/forgot_password.json", {
|
||||
data: { login: this.currentUser.username },
|
||||
type: "POST",
|
||||
});
|
||||
const result = await this.currentUser.changePassword();
|
||||
|
||||
if (result.success) {
|
||||
this.errorMessage = null;
|
||||
|
@ -585,8 +585,7 @@ export default class User extends RestModel.extend(Evented) {
|
||||
}
|
||||
|
||||
changePassword() {
|
||||
return ajax("/session/forgot_password", {
|
||||
dataType: "json",
|
||||
return ajax("/session/forgot_password.json", {
|
||||
data: { login: this.email || this.username },
|
||||
type: "POST",
|
||||
});
|
||||
|
22
spec/system/page_objects/modals/confirm_session.rb
Normal file
22
spec/system/page_objects/modals/confirm_session.rb
Normal file
@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Modals
|
||||
class ConfirmSession < PageObjects::Pages::Base
|
||||
def click_forgot_password
|
||||
find(".confirm-session .confirm-session__reset-btn").click
|
||||
self
|
||||
end
|
||||
|
||||
def has_forgot_password_email_sent?
|
||||
has_css?(".confirm-session .confirm-session__reset-email-sent")
|
||||
end
|
||||
|
||||
def submit_password(password)
|
||||
find(".confirm-session input#password").fill_in(with: password)
|
||||
find(".confirm-session .btn-primary:not([disabled])").click
|
||||
self
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -8,10 +8,14 @@ module PageObjects
|
||||
self
|
||||
end
|
||||
|
||||
def visit_second_factor(user, password)
|
||||
def click_manage_2fa_authentication
|
||||
click_button "Manage Two-Factor Authentication"
|
||||
find(".confirm-session input#password").fill_in(with: password)
|
||||
find(".confirm-session .btn-primary:not([disabled])").click
|
||||
PageObjects::Modals::ConfirmSession.new
|
||||
end
|
||||
|
||||
def visit_second_factor(user, password)
|
||||
click_manage_2fa_authentication.submit_password(password)
|
||||
|
||||
expect(page).to have_current_path("/u/#{user.username}/preferences/second-factor")
|
||||
self
|
||||
end
|
||||
|
@ -21,8 +21,17 @@ describe "User preferences | Security", type: :system do
|
||||
shared_examples "security keys" do
|
||||
it "adds a 2FA security key and logs in with it" do
|
||||
with_virtual_authenticator do
|
||||
user_preferences_security_page.visit(user)
|
||||
user_preferences_security_page.visit_second_factor(user, password)
|
||||
confirm_session_modal =
|
||||
user_preferences_security_page
|
||||
.visit(user)
|
||||
.click_manage_2fa_authentication
|
||||
.click_forgot_password
|
||||
|
||||
expect(confirm_session_modal).to have_forgot_password_email_sent
|
||||
|
||||
confirm_session_modal.submit_password(password)
|
||||
|
||||
expect(page).to have_current_path("/u/#{user.username}/preferences/second-factor")
|
||||
|
||||
find(".security-key .new-security-key").click
|
||||
expect(user_preferences_security_page).to have_css("input#security-key-name")
|
||||
|
Reference in New Issue
Block a user