THshadow Posted February 12, 2018 Posted February 12, 2018 I have Facebook set up on my forum to allow people to register easily with their account. This works fine in the normal practice of things, such as clicking on the signup button and going through the flow. I am using IP.Pages and have a public (Guest viewable) page on my site that I want to put this Facebook button on to allow them to easily click and register right from there. How can I go about doing this, and at the same time, not display this button if they are already logged in? Update Using pages, I created a block for this button that I only show to guests which works fine. The content of this block is: <a href='{$url}' class='ipsButton ipsButton_verySmall ipsButton_fullWidth ipsSocial ipsSocial_facebook'> <span class='ipsSocial_icon'><i class='fa fa-facebook'></i></span> <span class='ipsSocial_text'>{lang="login_facebook"}</span> </a> The issue with this is that the following doesn't get parsed because it doesn't know what to put there. {$url} Is there a global variable I can use that will give me the Facebook login url? Hardcoding it like this throws a CSRF error because its missing part of the variable which is normally included on the front end. https://www.facebook.com/dialog/oauth?client_id=2076774779217739&scope=email,user_posts,publish_actions&redirect_uri=http://domain.com/applications/core/interface/facebook/auth.php
THshadow Posted February 13, 2018 Author Posted February 13, 2018 I found the template for this button located here - Core > Global > Login > facebook in the main forum system. I tried adding this to the page content but I think it crashed, got a server error when trying this. {template="facebook" app="core" group="global" location="login" params=""}
THshadow Posted February 13, 2018 Author Posted February 13, 2018 After playing around with this, I finally got something working, although, it feels hackish. {{if !\IPS\Member::loggedIn()->member_id}} <a href='https://www.facebook.com/dialog/oauth?client_id=2076774779217739&scope=email,user_posts,publish_actions&redirect_uri=http://mydomain.com/applications/core/interface/facebook/auth.php&state=front-{expression="\IPS\Session::i()->csrfKey"}-{expression="base64_encode('http://mydomain.com')"}' class='ipsButton ipsButton_verySmall ipsButton_fullWidth ipsSocial ipsSocial_facebook'> <span class='ipsSocial_icon'><i class='fa fa-facebook'></i></span> <span class='ipsSocial_text'>{lang="login_facebook"}</span> </a> <br /> {{endif}} I look forward to a better suggestion to this, especially a dynamic URL variable so I don't have to hardcode it into the block like that.
Numbered Posted February 13, 2018 Posted February 13, 2018 I don't know. But i'll start this job with something like that: {{$fb = \IPS\Login\LoginAbstract::load('Facebook');}} {{$fbLoginForm = $fb->loginForm(\IPS\Http\Url::internal(''));}} .. {$fbLoginForm|raw} \IPS\Http\Url::internal('') - just for error preventing. It's not using with form generation. Anyway, you can see how this url generated in \IPS\Login\Facebook class (\system\Login\Facebook.php, loginForm method)
THshadow Posted February 13, 2018 Author Posted February 13, 2018 5 hours ago, Upgradeovec said: I don't know. But i'll start this job with something like that: {{$fb = \IPS\Login\LoginAbstract::load('Facebook');}} {{$fbLoginForm = $fb->loginForm(\IPS\Http\Url::internal(''));}} .. {$fbLoginForm|raw} \IPS\Http\Url::internal('') - just for error preventing. It's not using with form generation. Anyway, you can see how this url generated in \IPS\Login\Facebook class (\system\Login\Facebook.php, loginForm method) Thanks for the info - I will try this later today. What i have is working but is obviously not the correct way to do things
Recommended Posts
Archived
This topic is now archived and is closed to further replies.