Helper function to rewrite the destination to avoid redirecting to login page after login.
Third-party authentication modules may use this function to determine the proper destination after a user has been properly logged in.
function user_login_destination() {
$destination = drupal_get_destination();
// Modules may provide login pages under the "user/login/" path prefix.
if (preg_match('@^user/login(/.*|)$@', $destination['destination'])) {
$destination['destination'] = 'user';
}
return $destination;
}