Skip to:
Content
Pages
Categories
Search
Top
Bottom

Incorrect redirection to specific message when user not logged in

  • @astahov006

    Participant

    Hello!

    User receives notification email about a new message in chat. He follows message link in email and if he is not currently logged into the site he sees 404 error page instead of login form.

    The reason is incorrect redirection url that has the extra “/” after login.php:
    https://infosecportal.ru/wp-login.php/?redirect_to=https%3A%2F%2Finfosecportal.ru%2Fpolzovateli%2Fpauls%2Fbp-messages%2F#/conversation/11

    And if I manually remove this undue “/” from the address bar and log in, then I am redirected only to https://infosecportal.ru/polzovateli/pauls/bp-messages/, and not to a specific message url https://infosecportal.ru/polzovateli/pauls/bp-messages/#/conversation/11.

    And I see the message: “You must be authorized to access the requested page”.
    I use the last versions of WP and BP.

Viewing 5 replies - 1 through 5 (of 5 total)
  • @astahov006

    Participant

    Hello!

    Is anybody here from tech support?

    Regards, Alex

    @emaralive

    Moderator

    Hi,

    BuddyPress doesn’t have chat. Out of curiosity, what plugin are you using for chat?

    @astahov006

    Participant

    I use Better Messages but it doesn’t matter. I deactivated this plugin and it didn’t help.
    I see https://infosecportal.ru/wp-login.php/?redirect_to ... when I try to open message in BP.

    @emaralive

    Moderator

    The URL provided in the email notification is just to a page that requires access by an appropriate logged-in user. The issue appears to be related to the process that is constructing the redirect URL. The example you provided appears to be mangled for an unknown reason:

    https://infosecportal.ru/wp-login.php/?redirect_to=https%3A%2F%2Finfosecportal.ru%2Fpolzovateli%2Fpauls%2Fbp-messages%2F#/conversation/11

    The slash that is after wp-login.php seems to be misplaced, additionally, there should be a slash after 11 and then I would expect &bp-auth=1&action=bpnoaccess after that.

    The redirect is constructed in the function bp_core_no_access() which can be viewed at the following URL for BP 14.3.4:

    https://github.com/buddypress/buddypress/blob/14.3.4/src/bp-core/bp-core-catchuri.php#L328-L405

    Typically, $mode is equal to 2 which will then execute the code represented by lines 371 through 381: i.e.:

    		case 2:
    			if ( ! empty( $redirect ) ) {
    				bp_core_redirect(
    					add_query_arg(
    						array(
    							'bp-auth' => 1,
    							'action'  => 'bpnoaccess',
    						),
    						wp_login_url( $redirect )
    					)
    				);

    $redirect should be the URL that is represented in the email notification. The function wp_login_url(), which is a WordPress function, constructs/builds the redirect URL. The function wp_login_url() without arguments should, in your case, return:

    
    https://infosecportal.ru/wp-login.php
    

    The fact that there is a slash after the .php indicates that you should look there for why the slash is present, see the following regarding information on wp_login_url():

    wp_login_url()

    @astahov006

    Participant

    Thank you @emaralive.
    Youzify plugin mangles redirect URL. I’ve written to their support forum.

    Regards, Alex

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar