mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 13:35:20 -05:00
FIX: move hp request from /users to /token (#10795)
`hp` is a valid username and we should not prevent users from registering it.
This commit is contained in:
@@ -47,6 +47,9 @@ class ApplicationController < ActionController::Base
|
||||
after_action :dont_cache_page
|
||||
after_action :conditionally_allow_site_embedding
|
||||
|
||||
HONEYPOT_KEY ||= 'HONEYPOT_KEY'
|
||||
CHALLENGE_KEY ||= 'CHALLENGE_KEY'
|
||||
|
||||
layout :set_layout
|
||||
|
||||
def has_escaped_fragment?
|
||||
@@ -833,6 +836,14 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
protected
|
||||
|
||||
def honeypot_value
|
||||
secure_session[HONEYPOT_KEY] ||= SecureRandom.hex
|
||||
end
|
||||
|
||||
def challenge_value
|
||||
secure_session[CHALLENGE_KEY] ||= SecureRandom.hex
|
||||
end
|
||||
|
||||
def render_post_json(post, add_raw: true)
|
||||
post_serializer = PostSerializer.new(post, scope: guardian, root: false)
|
||||
post_serializer.add_raw = add_raw
|
||||
|
||||
@@ -451,6 +451,17 @@ class SessionController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def get_honeypot_value
|
||||
secure_session.set(HONEYPOT_KEY, honeypot_value, expires: 1.hour)
|
||||
secure_session.set(CHALLENGE_KEY, challenge_value, expires: 1.hour)
|
||||
|
||||
render json: {
|
||||
value: honeypot_value,
|
||||
challenge: challenge_value,
|
||||
expires_in: SecureSession.expiry
|
||||
}
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def check_local_login_allowed(user: nil, check_login_via_email: false)
|
||||
|
||||
@@ -35,7 +35,6 @@ class UsersController < ApplicationController
|
||||
skip_before_action :verify_authenticity_token, only: [:create]
|
||||
skip_before_action :redirect_to_login_if_required, only: [:check_username,
|
||||
:create,
|
||||
:get_honeypot_value,
|
||||
:account_created,
|
||||
:activate_account,
|
||||
:perform_account_activation,
|
||||
@@ -643,17 +642,6 @@ class UsersController < ApplicationController
|
||||
}
|
||||
end
|
||||
|
||||
def get_honeypot_value
|
||||
secure_session.set(HONEYPOT_KEY, honeypot_value, expires: 1.hour)
|
||||
secure_session.set(CHALLENGE_KEY, challenge_value, expires: 1.hour)
|
||||
|
||||
render json: {
|
||||
value: honeypot_value,
|
||||
challenge: challenge_value,
|
||||
expires_in: SecureSession.expiry
|
||||
}
|
||||
end
|
||||
|
||||
def password_reset_show
|
||||
expires_now
|
||||
token = params[:token]
|
||||
@@ -1522,19 +1510,6 @@ class UsersController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
HONEYPOT_KEY ||= 'HONEYPOT_KEY'
|
||||
CHALLENGE_KEY ||= 'CHALLENGE_KEY'
|
||||
|
||||
protected
|
||||
|
||||
def honeypot_value
|
||||
secure_session[HONEYPOT_KEY] ||= SecureRandom.hex
|
||||
end
|
||||
|
||||
def challenge_value
|
||||
secure_session[CHALLENGE_KEY] ||= SecureRandom.hex
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def password_reset_find_user(token, committing_change:)
|
||||
|
||||
Reference in New Issue
Block a user