Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

I've considered doing this, though really a full redirect is the safest way to log into Facebook as a user can always see the URL of the browser (which helps prevent phishing) while avoiding pop-up blockers and users who can only handle one window at a time.

It's definitely an option, but I don't have any plan on implementing it. Using a modal window is frowned upon from a security perspective and it's bad practice to teach users to blinding enter in login/pass into an iframe where they can't even see the URL. So popup is the only real option here, which I'm just not very excited about implementing.

Anonymous’s picture

OK, clear. I was used to the FB Connect module which does a popup with address bar ;) I switched to FBOauth because it's cleaner, better. I'm fine with the redirect. And maybe I'll have a look at something like this for a custom implementation,
https://apps.facebook.com/oauth-and-popup/

quicksketch’s picture

Status: Active » Postponed

Moving this to postponed. Really I'd say this is "by design", but I'll leave it open for others who may make similar requests.

grasmash’s picture

@morningtime If you successfully created a custom solution for this, would please share?

grasmash’s picture

I managed to get a facebook login popup working with FBOauth by using facebook's Javascript SDK. I'm not crazy about it, but it works.

I thought I should post the code here for a couple of reasons:

  • In case it may help someone else
  • I'm hoping that quicksketch can weigh in and let me know if there's a better way to do this.

The basic tasks that need to be performed to implement this are:

  1. Add the app_id and request_uri to Drupal.settings
  2. Load the Javascript SDK
  3. Modify the Javascript SDK so that it returns the access token via $_REQUEST
  4. Modify fboauth_action_page() so that it checks for access token in $_REQUEST
  5. Override theme_fboauth_action__connect()

Yuck! My concerns here are that we're potentially exposing the access token in the URL.

Any ideas for improvement?

Here are the steps in detail:

1) Generate page markup (I did this via a custom block):

      // Build the return query string.
      $query = array();
      if (isset($redirect)) {
        $query['destination'] = $redirect;
      }
      elseif (!empty($_GET['destination'])) {
        $query['destination'] = $_GET['destination'];
      }
      $settings = array(
        'mymodule_registration' => array(
          'appId' => variable_get('fboauth_id', ''),
          'redirect_uri' => fboauth_action_url('fboauth/connect', array('absolute' => TRUE, 'query' => $query)),
          //'channelUrl' => '',
        ),
      );
      drupal_add_js($settings, 'setting');
      drupal_add_js( drupal_get_path('module', 'mymodule_registration') . '/js/fb-js-sdk.js', array('type' => 'file'));
      $content[] = fboauth_action_display('connect');
      $content[] = '<div id="fb-root"></div>';
      return implode($content);

2) Add the javascript file called by drupal_add_js:

(function ($) {
  Drupal.behaviors.mymodule_registration = {
    attach: function (context, settings) {
      window.fbAsyncInit = function() {
        FB.init({
          appId      : Drupal.settings.mymodule_registration.appId, // App ID
          //channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          xfbml      : true,  // parse XFBML
          oauth      : true,
        });
        // Additional initialization code here

        FB.Event.subscribe('auth.login', function(response) {
          window.location = Drupal.settings.mymodule_registration.redirect_uri + '?access_token=' + response.authResponse.accessToken;
        });
      };

      // Load the SDK Asynchronously
      (function(d){
       var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       ref.parentNode.insertBefore(js, ref);
      }(document));
    }
  };
}(jQuery));

3) Modify the default connect button using theme_fboauth_action__connect():

function my_theme_fboauth_action__connect($variables) {
  $link = $variables['properties'];
  $title = isset($link['title']) ? check_plain($link['title']) : '';
  return '<fb:login-button show-faces="false" scope="' . $variables['properties']['query']['scope'] . '">' . $title . '</fb:login-button>';
}

4) Modify fboauth.fboauth.inc. This is the part that I don't like, but I think that it's necessary. The Javascript SDK won't return $_REQUEST['code'], which is required by fboauth_action_page() when it calls fboauth_access_token().

However, the Javascript SDK does return the access token directly, so there's no need to call fboauth_access_token(). That means we just need to modify fboauth_action_page() so that it checks for the access code returned by Javascript.
@line 36 in fboauth.fboauth.inc:

  elseif (!isset($_REQUEST['code']) && !isset($_GET['access_token'])) {
    watchdog('fboauth', 'A Facebook request code was expected but no authorization was received.');
  }
  // The primary action routine after access has been approved by the user.
  else {
    if (isset($_REQUEST['access_token'])) {
      $access_token = $_REQUEST['access_token'];
    }
    else {
      $access_token = fboauth_access_token($_REQUEST['code'], $action_name, $app_id, $app_secret);
    }  
    if (isset($access_token)) { 
      $destination = fboauth_action_invoke($action_name, $app_id, $access_token);
      if (empty($destination)) {
        $destination = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : '<front>';
      }
      drupal_goto($destination);
    }
  }

  // In the event of an error, we stay on this page.
  return $error_message;
}
grasmash’s picture

Further thoughts:

Facebook's oauth authentication api does allow us to pass a 'display' parameter with value 'popup' in the $_GET array. However, this does not change the redirect functionality-- it simple styles the authorization in the style of a popup.

We could use this in conjunction with Javascript to open the authentication page in a popup. I tried this, but ran into the following issue: there's no way to pass information back to the parent window, which will need to be redirected to request_uri with the $_REQUEST['code'] value.

Any ideas for getting around this?

grasmash’s picture

Ack. Just realized that code from #5 only works for initial registration, not subsequent logins.

quicksketch’s picture

Thanks @madmatter23 for your insights. Could the display parameter being set to "popup" help with the problem at #1491272: Go to App vs. Login?? Maybe we should always ask for the popup version even though we're not actually doing a popup.

grasmash’s picture

I also considered setting the display to 'popup' for all requests. Unfortunately, the popup display is styled (CSS) for popup display. Using it with a fullscreen browser results in a poor user experience. For instance, the 'allow' button will appear in the far bottom-right hand corner of a user's screen when granting facebook permissions.

guy_schneerson’s picture

thanks @madmatter23,

Re #5 point 4
Modify fboauth.fboauth.inc. -
I think this is a valid patch as it supports both the handling of a request with a code or a request with a token, this makes the module more versatile.
I am including your code as a patch (even if it not committed would make it easier to support this functionality when upgrading)

re #7
We use FB.getLoginStatus(function(response) to check if the user is already connected (authorized our app) and if he is get the token:
var accessToken = response.authResponse.accessToken;
and call fboauth/connect to automatically log the user in

grasmash’s picture

@guy_schneerson

Thanks for rolling that patch. If quicksketch commits it, I'll add the 'popup' feature my sandbox Facebook OAuth Extras module (still very messy) so that others can more easily emulate it.

Also, thanks for addressing #7. I'll try using FB.getLoginStatus() to handle subsequent logins.

grasmash’s picture

Status: Postponed » Needs review

Just gonna switch this status now that there's a patch attached.

ofktoubro’s picture

I just did:
Step 1, 2, 3 in #5 and applied the patch in #10

And it seems to work... Clicking the buttons results in a popup, the text is "Log in" not "Connect" and the facebook authorize button in the popup says "Log in" and not "Go to app" - GREAT! :)

Except:

  1. The new "Log in" button in the custom block (#5,1) doesnt disapear when I log in.
  2. And when I set the block to only be visible for anynomous users it goes away but it breaks my other facebook elements. (I have "like" and "Comment" via "Facebook social plugins integration" module)

I really want the "Log in" button to go away and the functionality of both "FBOauth" and "Facebook social plugins integration".

ofktoubro’s picture

Ok, it turned out that I hadn't put the app id in the "Facebook social plugins integration" settings... And that caused the display error mentioned in #13-2.

relaxy’s picture

Does somebody know how to make it work with Drupal 6?

relaxy’s picture

=> #15

For Drupal 6 we just have to modify the JavaScript this way:

(function ($) {
  Drupal.behaviors.mymodule_registration = function (context, settings) {
      window.fbAsyncInit = function() {
        FB.init({
          appId      : Drupal.settings.mymodule_registration.appId, // App ID
          //channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
          status     : true, // check login status
          cookie     : true, // enable cookies to allow the server to access the session
          xfbml      : true,  // parse XFBML
          oauth      : true,
        });
        // Additional initialization code here

        FB.Event.subscribe('auth.login', function(response) {
          window.location = Drupal.settings.mymodule_registration.redirect_uri + '?access_token=' + response.authResponse.accessToken;
        });
      };

      // Load the SDK Asynchronously
      (function(d){
       var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       ref.parentNode.insertBefore(js, ref);
      }(document));
    };
}(jQuery));
relaxy’s picture

=> #7

The quick and dirty solution would probably be to disconnect the user right after login:


FB.getLoginStatus(function(response) {
            if (response.status == "connected") {
          		FB.logout(function(response) {
          		}); 
	        }
          });

Frederic wbase’s picture

@guy_schneerson

I've tryed to apply your patch, but i get the following error:

:~/drupal-7.15-dev/sites/m_site/modules/contrib/fboauth$ patch < support_access_tokens_1364698_10.patch 
patching file fboauth.fboauth.inc
Hunk #1 FAILED at 33.
1 out of 1 hunk FAILED -- saving rejects to file fboauth.fboauth.inc.rej
frederic@aegir:~/drupal-7.15-dev/sites/m_site/modules/contrib/fboauth$ 

any thoughts?

grts

Frederic

Frederic wbase’s picture

Ok, i 've aplyed the patch by moving it into the includes folder.
But i still get no popup :(

guy_schneerson’s picture

Hi Frederic
re #18 did you manage to apply the patch?
re #19 The patch doesn't change the login into a popup but facilitates it. you will need to add custom code and a Javascript to get this functionality.
If the patch in #10 is committed we will be able to create a supporting module for popup login

Frederic wbase’s picture

Hey Guy

Thanks for your support!

I've managed to apply the patch from #18.

Tonight i will break my head for the custom code that is needed for creating the popup, i will post my comments in this topic.

grts

frederic

Frederic wbase’s picture

Mhmm i've tried everything in this thread, but the button doesn't display correctly.

I've added the custom block and js via a custom module, patched the fboauth module & added the theme function in template.php of my theme

Now i get this html markup

<article>
<fb:login-button show-faces="false" scope="email,user_birthday,user_hometown"></fb:login-button><div id="fb-root"></div>
</article>

but no image or text at all, any ideas?

Frederic wbase’s picture

FileSize
3.94 KB

In the attachment the module i've created for this with the code suplied in this thread

tiborg’s picture

@Frederic wbase

how to work this module? i installed, but i don't see nothing change. How do i to enable? or i need the patch above?

thank you

Frederic wbase’s picture

@tiborg

The module doesn't work.
I've uploaded it to let others see it and maybe we can create a sollution together.

The module is based on the code of #5.
You will still need to apply the patch and theme adjustments in template.php

grts

frederic

ffasbend’s picture

FileSize
8.72 KB

I wrote a custom module for Drupal 6 to enable fboauth connect in a popup window.

  • There is no need to patch fboauth.
  • Drupal behaviors is used to make all facebook buttons (class 'facebook-action-connect') open in a popup.
  • Facebook is told by fboauth to respond at the path 'fboauth/%fboauth_action', so i wrote a more specific menu callback 'fboauth/connect' just for the facebook connect functionality, thus getting the response from facebook on this path. The function at this path just closes the popup and redirects (via javascript) to the original fboauth path, which has been duplicated at a new path 'fboauth_orig/%fboauth_action' (because original is not reachable anymore by facebook connect). The parameters originally returned by facebook are all passed along.
  • I also created different fb-buttons with translatable text: sign-in shown on login-form, sign-up shown on user registration form
  • There's a facebook connect block, which only appears if user is logged in and has not yet connected with facebook (also translatable text).
Frederic wbase’s picture

Hey ffasbend

Thanks for this great addition to this thread.
I've tried to install your module on a drupal7 site, by just changing the .info file.

The module install without errors. But when i try to login to my drupal site with the fb button it redirects to a blank page.

Any thoughts?

Jorrit’s picture

The posts above are about getting a proper modal dialog, but for me a browser popup was sufficient. The advantage is that it is only one line of code (apart from the function definition):

function YOURMODULEORTHEME_preprocess_fboauth_action__connect(&$variables) {
  $variables['properties']['attributes']['onclick'] = 'window.open(this.href + \'&display=popup\', \'blank\', \'menubar=0,resizable=0,width=640,height=400\'); return false;';
}

I hope it helps some people.

[edit] this is not a full fix, because the redirect_uri will be opened in the popup. Some code has to be added to that dialog in order to close the popup and refresh the opener.

MarcElbichon’s picture

FileSize
5.79 KB

Here's #26 for Drupal 7.
Works for me.

MarcElbichon’s picture

FileSize
7.53 KB

Based on #26 code, here's a patch for Drupal 7 which adds a setting to show facebook login page in popup.
Patch for Drupal 6 will be post soon

MarcElbichon’s picture

FileSize
6.28 KB

Here's #30 for Drupal 6

quicksketch’s picture

Status: Needs review » Needs work
FileSize
6.72 KB

Thanks @MarcElbichon for converting this code to a patch. Though it wasn't in the standard Git format (http://drupal.org/patch/create), I got it applied eventually after some clean up.

The code needed some serious cleanup, but the overall approach looks really solid. I'm impressed that the code weight is so small. After my cleanup, there's even less code than before. This patch does the following:

- Eliminates the need for new menu entries.
- Makes it so that popups can be used for all Facebook actions, not just the connect button.
- Cleans up formatting and matches Drupal coding standards.

However there are still a few outstanding issues that need to be addressed before this can be committed:

- Not all actions should be forced to use the popup (IMO). We should have some way of letting actions opt-out of using the popup in hook_fboauth_actions().
- I couldn't find a good/easy way to indicate that a request being handled by FBOAuth had originated in a popup. Ideally we would pass Facebook a parameter in the query string that could come back to us when we're using a popup. Then we could be sure that we can close the popup with JavaScript instead of redirecting the user via drupal_goto().

Overall the idea seems to work great. We still need a bit of extra work before this is ready to go though. This patch is for D7. We can backport once its finished.

quicksketch’s picture

FileSize
6.25 KB

Sorry still a little cruft left over.

quicksketch’s picture

One last thing: I also found that this popup JS doesn't center the popup properly when I'm using two monitors and the active window is on the secondary monitor. The popup instead shows up over in my first monitor, which could be disorienting for users and they may loose the popup window.

MarcElbichon’s picture

sandykadam’s picture

Patch fboauth_popup_2.patch is working perfect. It opens a popup window dialog box, but it doesn't close automatically. Also it doesn't redirect to parent window.

StoraH’s picture

The code in the patch #33 works great, thanks! Had problem applying it tho: fatal: corrupt patch at line 160

Created a new one with the same code that worked for me.

Anonymous’s picture

Status: Needs work » Reviewed & tested by the community

#37 works great for me too.

It closes automatically and redirects to the parent window, works perfect.

@#34 we can improve centering on multiple displays... but I would go ahead with the patch as-is.

imoreno’s picture

Hi,
#37 works great for me too, I think it can be committed.

the user experience is much better and also more familiar to the user from other facebook-login enabled sites.
very nice and needed enhancement.

Itzhak

sigveio’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
7.41 KB

The patch in #37 is not compatible with a scenario where the login form is displayed within a modal dialog, such as the ctools modal generated by the Modal forms module. It will grab the path of the modal instead of the parent window, and the user will (at least in my case) end up back at their profile page.

An e-commerce site who needs to offer login through a modal window during the checkout process, as an example, would run into issues with this. The user being sent away from the checkout page can result in lost sales.

Luckily, the solution is quite straight forward. I've created a patch based on #37, additionally adding the corrected destination handling.

It modfies fboauth_block_view() and replaces...

$redirect = (arg(0) === 'user' && (arg(1) === 'login' || arg(1) == '')) ? NULL : $_GET['q'];

with

$destination = drupal_get_destination();
$redirect = (arg(0) === 'user' && (arg(1) === 'login' || arg(1) == '')) ? NULL : $destination['destination'];

Which seems to do the trick for me. :)

quicksketch’s picture

Thanks @hoesi! And as I noted when I originally posted the patch, before this is RTBC, it would be preferable if we could selectively disable the popup option per-action.

MarcElbichon’s picture

Can you provide a patch for D6 too ?

Pls’s picture

Nice work @hoesi! Patch from #40 works great for native popup functionality, haven't tested modal dialog. Would be happy to see this feature part of the module.

tomecruzz’s picture

Hello I used the patch: fboauth-popup_modal_compatible-1364698-40.patch
but don't work :( dialog modal

$ patch -b -p 1 < fboauth-popup_modal_compatible-1364698-40.patch

patching file fboauth.install
patching file fboauth.module
patching file fboauth_popup.js
patching file includes/fboauth.fboauth.inc
patching file includes/fboauth.pages.inc

sigveio’s picture

The patch works fine for me and others (I'm using it in production). You'll have to be a bit more specific tomecruzz. What doesn't work, and which modules are you using it with? There could be numerous reasons to why you are experiencing issues.

codewatson’s picture

#40 seems to work for the most part for me, however I had setup a rule to redirect to a url after someone logged in, and with the popup enabled this seems to no longer get triggered?

Update:
Ok well apparently it wasn't working regardless, so I guess the rule condition for detecting if someone just logged never gets triggered when using fboauth.

sigveio’s picture

Sounds like the culprit is the rule itself. You'd have to post the rule (exported) for anyone to chime in on that, though.

The point of my addition in #40 is to fix the redirection so that it respects Drupal's destination URL param. I.e. so that if the login-link contains ?destination=your/url/goes/here - the user would end up at your/url/goes/here after logging in. Perhaps you can use this instead of the rule? :)

codewatson’s picture

Thanks for the response, as for the rule, its just the basic "User has logged in" event that comes with rules and then the "Page redirect" action. Not sure why that event wouldn't be triggered by logging in through Facebook?

Here's the export:

{ "rules_dashboard_redirect" : {
    "LABEL" : "Dashboard Redirect",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_login" ],
    "DO" : [ { "redirect" : { "url" : "dashboard" } } ]
  }
}

Regardless, I figured out that you can include the destination in the fboauth_action_display()/fboauth_action_link_properties() functions, so I got it all working how I need it to in the end (pretty much as you suggested!).

Ended up going with the fboauth_action_link_properties() function so I could customize how the link looked, and just added the fboauth-popup class to get it to open in the popup:

$link = fboauth_action_link_properties('connect', $_GET['q']);
print l(t('Connect with Facebook'), $link['href'], array('query' => $link['query'], 'attributes' => array('class' => array('fboauth-popup'))));

This all seems to be working well enough, you could probably commit the patch, and figure out the by action part later, as I imagine many people who use or would use this module would like the popup feature.

skchan2’s picture

Thanks for this, patch #40 worked perfectly.

Would anyone be abe to point me to instructions on adding a hook into my custom module that would redirect new registers to a specific page that works with the popup?

#14 from the below thread works, but not with the popup. it just redirects in the popup window

https://drupal.org/node/1761954

codewatson’s picture

@skchan2

Try this, just replace 'http://www.google.com' with wherever you want to send someone:

<?php
$link = fboauth_action_link_properties('connect', 'http://www.google.com');
print l(t('Connect with Facebook'), $link['href'], array('query' => $link['query'], 'attributes' => array('class' => array('fboauth-popup'))));
?>
skchan2’s picture

@dwatson

just tried that, it loaded the page in the main window, but didn't log the user in...something seems to be missing, also how would i use a custom image for the button?

thanks for your help.

codewatson’s picture

Hmm strange, works for me. Maybe double check the patch was applied correctly?

Also, try it without the popup, see if that is working correctly, might tell is if it is just the popup or something else is wrong.

As for an image button, take a look at the l() function in the drupal api, the $options parameter (the third one) you can set html to true, so that drupal treats the first parameter $text as html instead of plain text. You can then set $text to html for an image.

ex:

$link = fboauth_action_link_properties('connect', 'http://www.google.com');
$image = '<img src="path_to_my_image.jpg" />';
print l($image, $link['href'], array('query' => $link['query'], 'attributes' => array('class' => array('fboauth-popup')), 'html' => TRUE));
skchan2’s picture

Thanks for the image tip.

hmm...weird doesn't create the profile with or without the popup...am i missing something, another patch maybe?

I only apply the #40 patch using netbeans.

Thanks,

codewatson’s picture

OK did some experiments. Question one, which version did you apply the patch to? I found that if I applied the patch to 7.x-1.6, everything works just fine. If I apply the patch to 7.x-1.x-dev, the popup does not work correctly.

skchan2’s picture

i think i found the issue, i had old code from testing out other methods...cleaned it out and now its all good.

Thanks for your help.

codewatson’s picture

Status: Needs review » Needs work

Glad to help.

Unfortunately, as I discovered, this patch does not work correctly with the latest development snapshot, haven't had time to look into why.

sigveio’s picture

@dwatson: Care to elaborate on "this patch does not work correctly" please?

What's supposedly broken/not working? And what makes you believe it's an issue with the patch itself?

It seems to apply cleanly (to latest dev);

$ patch -p1 < fboauth-popup_modal_compatible-1364698-40.patch
patching file fboauth.install
patching file fboauth.module
patching file fboauth_popup.js
patching file includes/fboauth.fboauth.inc
patching file includes/fboauth.pages.inc

Which makes me suspect there might be something else that's broken in your case. E.g. conflicting modules/code, or something.

I'll see about setting up a new/clean test environment a bit later and verify whether things are working, as I've got the original environment for #40 at work. Any information you can provide in the meantime would be helpful. I don't have a lot of time to spend on it either.

codewatson’s picture

I setup a clean environment and tested the patch on both the 7.x-1.6 and 7.x-1.x-dev. The patch applied cleanly to both. However, the popup would not work on the dev version for some reason, not sure why, and haven't had a chance to investigate further.

codewatson’s picture

Status: Needs work » Needs review

Well just tried it again on a fresh install with the dev version and this time it worked, maybe it was a caching issue in-between versions or something, as i made sure i cleared it between installing the 1.6 and dev.

sigveio’s picture

Great to hear - thanks for double checking it. :)

mike.davis’s picture

Here is an updated patch based upon #40 with various enhancements and bug fixes for the following:

  • Moved the including of the JS file for the popup to only be included when the block is included rather than on every page load
  • When a user cancels their connection to Facebook:
    • Redirects the user to either the home page or to their user edit page
    • Displays the error message on the relevant page rather than displaying it on a separate page. This helps the user journey to be more relevant
    • This may also fix issue #1926880: Graceful return after visitor cancels app install
  • When popup was enabled, this wasn't being used within the user edit page
  • Applied change from issue #1876222 - Access token failure when Facebook is responding slowly
  • Various Coder Review fixes
mike.davis’s picture

Sorry I missed the additional js file for the popup window in the previous patch, so here is an updated patch.

mike.davis’s picture

I have updated this to redirect the user to their edit page (if the password is blank) on connecting to Facebook to show the warning message about their account not having a password.

This helps to highlight to the user that their account has been created but doesn't have a password against it.

joco_sp’s picture

#63 worked for me on version 7.x-1.6

asak’s picture

#63 worked fine for me.

only thing i found - the add .js file is being added in the code of the block, but when using code to directly place a connect button not using the block it is not added, so i had to add it manually. I think optimally a checkbox can be provided to let the admin chose if they want to include the JS in every page or not and then add it in hook_init() or the like.

Other then that - works like a charm.

mike.davis’s picture

Hi asak, thanks for reviewing the patch & your suggestion. I have updated the patch, as suggested, with an additional checkbox which will load the js file on every page load rather than just when the block is loaded.

Let me know how you get on with this.

asak’s picture

Yea that's better - however, one more issue i noticed regarding this -
The JS should actually not be loaded on the "deauthorize" page, since it's not needed there and opens an empty popup ;)
So i guess that even when the variable is set to TRUE, it should still not load on the /fboauth/ path ...

I suppose the correct thing to do is to make the JS not trigger for the de-auth button,
but since a user should never have both the de-auth button AND the connect button showing on the same page - this isn't necessary...

altamar17’s picture

FileSize
5.79 KB

Here's #26 for Drupal 7.
Works for me. Good lucky.

krystlc’s picture

#68 works great except the button doesn't appear on my registration form (the code says it will appear there).

other than that, it's perfect!

dunklea’s picture

From this snippet in patch in #66 it looks like the user will be redirected to their user/edit page (or $destination if their password is somehow empty). I'm looking for a solution to keep the user on the same page, with query strings intact. Any advice?

Thanks,
Andrew

    if (variable_get('fboauth_popup', 0)) {
      // Close the popup and set the parent window to the target destination.
      $url = $user->pass == '' ? url("user/{$user->uid}/edit", array('absolute' => TRUE)) : url($destination);
      print fboauth_close_popup_window($url);
      drupal_exit();
sigveio’s picture

@dunklea: The snippet you are referring to looks to be for a particular error case. This part, from my #40 (also included in #66), makes sure to keep the user on the same page providing the appropriate destination is set:

+    $destination = drupal_get_destination();
+    $redirect = (arg(0) === 'user' && (arg(1) === 'login' || arg(1) == '')) ? NULL : $destination['destination'];
mike.davis’s picture

Good point @asak, typically the one bit I forgot to test :). I'll have a look at this and repost a patch to handle this as well.

mike.davis’s picture

Hi @asak, here is an updated patch with a fix for the deauthorise page.

ggarry’s picture

Issue summary: View changes

#69 did you figure out how to add it to registration page? It isn't showing for me either.

jomarocas’s picture

something have a patch with login with ajax, without reload the page

v8powerage’s picture

My redneck solution: In function theme_fboauth_action__connect put this:

$attributes . ' href="javascript:window.parent.location =\'' . $url . '\';">

It will stay in same window and reload it, instead of opening another one, git r done!

vlad.k’s picture

I couldn't apply the patch in #73 against the newest dev version, because it is already one year old and the module code has changed over time. Also the newly added js file was missing in #73. It took some time to figure things out and create a new patch. But the good news is that it works like a charm!

Please commit this!

I didn't do any functional changes, just integrated the changes manually in the current dev version of the code. The popup is great functionality, it works and all the good work already put into this issue gets lost for the community if it is not commited soon and the patch file stops working again.

Attached you find a version of the patch in #73 against the newest development version (from yesterday April 1st, and no this is no April prank...).

Please review and commit. It was really a pain to work things out manually, but now it is not much code and it works. It shouldn't be to much effort to review and commit. Please.

DarrellDuane’s picture

I tested this and its not working for me. When I click on the button it opens a new window. I've cleared my caches and run update.php. Anything else I can do to debug it? I do agree we need to get this in ASAP.

DarrellDuane’s picture

ok, I see the problem, I didn't turn it on. I'd like to have this feature turned on by default. I will set it up to be that way.

  • DarrellDuane committed 4e945c0 on 7.x-2.x authored by vlad.k
    Issue #1364698 by mike.davis, MarcElbichon, quicksketch, hoesi,...
DarrellDuane’s picture

OK, this functionality has been comitted to the 7.x-2.x-dev branch.

DarrellDuane’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

DarrellDuane’s picture

Ok, this didn't make it into 7.x-2.x-dev yet, putting it in now. Done.