Hi,

If a user visits the login/registration urls after a user is logged in they get Access Denied. Anyway to make this more friendly? Maybe redirect them to their profile view page?

Thanks.

CommentFileSizeAuthor
#8 1861378-403-8.patch3.29 KBluksak

Comments

TelFiRE’s picture

+1

pandorawombat’s picture

Anyone have any luck with this?

grasmash’s picture

Status: Active » Closed (works as designed)

This isn't really a p2rp issue– it's a drupal access issue.

There are a number of modules that modify Drupal's default 403 behavior:

TelFiRE’s picture

Uh, I don't want to change my 403s, I want them to be sent to a page that isn't a 403... am I missing something

codesmith’s picture

Title: Something more friendly than Access denied? » Redirect logged-in user to profile page rather than 403 if user visits login or registration url - like how /user works
Version: 7.x-1.12 » 7.x-2.x-dev
Category: support » feature
Status: Closed (works as designed) » Active
luthien’s picture

I kept getting ACCESS DENIED error after an user logins to the site and tries to visit any of the profile pages below:

[path], [path]/register, [path]/login, and [path]/password

if using user/, user/register, user/login, and user/pssword everything works fine.

With profile2 unique registration path all I get is a 403 error. It looks like a problem with the module, not a drupal access issue.

luthien’s picture

I used the custom error module to add a redirect. I was unable to get it to work with rules.

luksak’s picture

Status: Active » Needs review
StatusFileSize
new3.29 KB

Created a first patch which fixes this issue. Might need some work.

Status: Needs review » Needs work

The last submitted patch, 1861378-403-8.patch, failed testing.

Exploratus’s picture

+1

loparr’s picture

Issue summary: View changes

I solved it with rules path module. Just redirect logged in user to "user" path.

ladybug_3777’s picture

I was looking for a simple redirect solution for this 403 as well. I'll check out the rules path module.

sgdev’s picture

The Drupal Rules module can be used to accomplish this without the need for additional modules.

Add an event of "User has logged in" and an action of "Page redirect." Then simply add whatever path to which you'd like the logged in user to be redirected.

chrisfree’s picture

The way that core handles this is actually pretty clever. I wonder if it would be best to replicate that behavior by default? I was able to accomplish this by duplicating the way core does it:

<?php
/**
 * Implements hook_menu_site_status_alter().
 */
function mymodule_menu_site_status_alter(&$menu_site_status, $path) {
  if (user_is_logged_in()) {
    if ($path == 'some-path') {
      // If user is logged in, redirect to 'user' instead of giving 403.
      drupal_goto('user');
    }
    if ($path == 'some-path/register') {
      // Authenticated user should be redirected to user edit page.
      drupal_goto('user/' . $GLOBALS['user']->uid . '/edit');
    }
  }
}
?>

If there isn't something terribly wrong with this approach, I'd be happy to whip up a patch to accomplish this in a more generic way via this module.

addiction2code’s picture

I was thinking about going the rules route but it doesn't really make sense since I'm also using LoginToboggan which redirects users to a login if access is denied. If a user is to login using one of those pages I would assume they wouldn't be redirected to the correct destination.

luxpir’s picture

I did it the same as loparr in #11.

See: https://www.drupal.org/node/2224359#comment-11803930 for more info.

waqarit’s picture

#14 is nice way to do this.

ikeigenwijs’s picture

#14 ++