Ruby on Rails: Devise Authentication with JavaScript - javascript

In my RoR project, the user could drag and drop a JavaScript link to the browser's bookmark manager/bar.
The JavaScript link calls another JavaScript file, say LoadUserData.js.
I'm using Devise for authentication.
My question is: when the user click the bookmark:
If the user has logged in, the user data will be loaded;
Otherwise, the bookmark will redirect the user to the login page.
How to implement it?
Peter

Related

Django and wordpress simultanous logout

I have this project in which user simultaneously login into Django as well as Wordpress accounts.
To achieve Simultanous logout, I used Javascript to delete the authentication cookie of Wordpress and thus automatically logging out the user. This works fine as long as user clicks on "logout" button. On clicking logout a Javascript function is called and wordpress cookie is deleted and thus making user logged out of Wordpress and user is logged out of Django by using normal Django functionality.
Now the problem occurs when user directly type the logout url "localhost:8000/logout" in address bar, this directly send request to Django server and without involving any JavaScript to delete the Wordpress cookie.
How to achieve Wordpress logout in this situation when user directly types the logout url of Django?
Note:- Wordpress and Django server are running on same host with different port.
Can you try with an one more browser,
For an example:
In an main browser you will log a Django project, an private browser (crtl+shift+p in an Firefox) you can use word press project.

Linking Website Account with Facebook Messenger Bot

I want to add a login button to my bot so users can log in and I can store and extract a unique id (that I provide) for that user that I can use later to grab specific information. I'm having trouble following Facebook's documentation for this.
Right now I have generated a login button that when pressed links to my login page via an external pop up browser but right now when logged in, the page just redirects to my website. I also noticed that the URL that is popped up provides an account linking token but i'm not really sure what to do with this.
Do I have to write some code on my end to work with this interface or am I missing something? Also how can I get it so that the external browser closes after a user logs in.
Yes you have to write some code on your end to create a page and backend code that can:
1) Lookup PSID on FB Graph (Optional)
2) Do other account stuff (Optional)
3) Use redirect_uri to send the user back into the bot
The user has to click 'done' after Facebook shows the 'account linking successful' window.

How to authenticate iframe against AAD (oauth)

A (SharePoint Online) page has an iframe to a .NET MVC application. The MVC application lives in a separate domain. Both SharePoint Online and MVC app use AAD and allow access for the same users (AAD tenant)
Now when a user opens the SharePoint page (in Windows 7) the iframe fails to redirect user to the AAD login page (because this is disallowed - see OAuth not working inside an iframe or https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-23#section-10.13)
After unsuccessful googling I decided to play around with this a bit and came up with something that works but is ugly:
User signs in to SharePoint. The iframe on page is hidden
JavaScript (jquery) on page makes a jsonp call to the MVC app
If the call succeeds we show the iframe and are happy
If the call fails we redirect user to an MVC page (full redirect). We carry the current url in querystring
User authenticates against AAD
MVC page redirects user back to our SharePoint Online page
Now iframe successfully shows content and we are happy, except that the above solution has a lot of code to maintain:
JavaScript redirect logic
jsonp request (error handling not so straightforward. Actually this is timeout based)
extra MVC action to redirect user back
unoptimal ux (some waiting and redirects. Back button would cause trouble)
What would be a better solution or how these things are typically solved?
(another question would be why my home PC seems to show iframe content after only signing in once to SharePoint online)

on-click facebook login by php

i have a project that have option to log in with facebook.
but this option only work for the admin of the site
whenever any other user want to log in the site a form will appear and ask some info. if full fill the form and click register it shows a error message.
Now i want to remove the form part from the website and want onclick login for all user. here is the link of the site
https://dev.metarank.com/
please help me to find the solution
thanks in advance
If I am not wrong to create a Facebook login button you need to create an app to obtain api keys, right?
If it is the case the problem could be the following:
After testing the login button you have to make the app publicly available by passing a review process from Facebook, and then anyone will be able to login to your website with a Facebook account.
As said: this is the process for standard apps, at the moment I am not sure at all about if it is exactly the same process for logins.

Facebook's PHP SDK with custom login page instead of redirecting?

Is it possible to create a custom login page to use with facebook's PHP/JavaScript SDK? I'm developing a web app and it doesn't seem very user-friendly to redirect the user to the facebook page to login. For example, once you hit login it doesn't even let the user know its loading, just sits there until it logs in.
I was wondering if it's possible to use ajax or cURL to log the user into facebook through a form within my app.
No this is not possible, you have to use Facebook's OAuth protocol.
Have you tried their javascript solution? This does not take the user away from the page, but instead opens a popup which is less of an intrusion on the page.
The facebook api is just for you to obtain access credentials from their system. I do not know and until then I never saw no way to get credentials and log into facebook without the facebook api.

Categories