Angular Satellizer causing issues with Facebook login on mobile devices

Issue

Currently, I'm developing an application using Angular and have successfully integrated Facebook login through Satellizer. The functionality works flawlessly on desktop browsers; however, when accessed from mobile devices, it tends to be unreliable. In some cases, the login pop-up fails to close, leaving the main screen in a state of limbo where it displays the home page within the login pop-up rather than returning to the original requesting screen. Any insights into what might be causing this inconsistency would be greatly appreciated.

Code Snippet

Snippet showcasing the authentication process with Facebook:

var commonConfig = {
    popupOptions: {
     location: 'no',
     toolbar: 'yes',
     width: window.screen.width,
     height: window.screen.height
   }
};

var permissions = ["public_profile","email"];
$authProvider.facebook(angular.extend({}, commonConfig, {
  clientId: FacebookAppId,
  url: ApiUrl+'api/v1/facebook/auth',
  scope:permissions,
  scopeDelimiter:','
}));

This code block is executed upon clicking "connect using Facebook":

$scope.loginSocial = function () {
    $scope.disableSubmitBtn = true;
    $scope.showSpinner = true;

    $auth.authenticate('facebook')
      .then(function (result) {
        result = angular.fromJson(result.data.code)
        return AuthServerProvider.loginFb(result.facebookCode);
      },function (error) {
        $scope.status = 'facebook-error';
        $scope.disableSubmitBtn = false;
        $scope.showSpinner = false;
      })
      .then(function(){
        $scope.disableSubmitBtn = true;
        $scope.showSpinner = true;
      })

While this code segment functions correctly on desktop browsers, it encounters frequent failures when accessed from mobile browsers during the "$auth.authenticate('facebook')" step.

Answer №1

We encountered a similar issue when working with Satellizer. Our problem stemmed from how the redirectUri was being handled within angular ui.router. Upon revisiting the library documentation, we came across the following advice:

To prevent potential 404 errors, it is recommended to create server routes for each redirectUri URL that return a 200 OK status. Alternatively, you can create a custom template with a loading spinner. Currently, due to a 20ms interval polling, a popup may not stay visible long enough to display the custom template. However, there are plans to allow overriding this polling interval in the future.

In your code snippet above, you did not specify a redirectUri, which means it defaults to '/'. If this route clashes with another route in angular, the redirection may occur before Satellizer has a chance to process it. To avoid this issue, assign a specific redirectUri and handle it through angular routes.

For more information, please take a look at this post.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Changing the input to uppercase within Vue.js

I am looking to capitalize the input data from the user's full name model and would prefer if it is in Latin letters only. Utilizing Vue.js for Uppercase Conversion <p-input :value="value" @input="$emit('input', $event)&qu ...

I need to see the image named tree.png

Could someone assist me in identifying the issue with this code that only displays the same image, tree.png, three times? var bankImages = ["troyano", "backup", "tree"]; jQuery.each( bankImages, function( i, val ) { $('#imagesCon ...

What is the reason behind Angular's continued use of JSON for encoding requests? (specifically in $http and $httpParamSerializerJ

Is there a way to set Angular to automatically send requests as x-www-form-urlencoded instead of JSON by default? Angular version 1.4.5 I've tried the following code snippet but it doesn't seem to work: angular.module('APP').config( ...

Encountering Routing Issues in Express.js Following Passport.js Authentication

My authentication setup with Passport.js is pretty straightforward. After the user successfully authenticates, I redirect them to /work like this. app.post('/login', passport.authenticate('local', { successRedirect: '/ ...

The dimensions of the d3 div remain constant despite any modifications to its attributes

In my angular application, I am trying to customize the width and height of div elements in d3 when I select a legend. Strangely, I am able to adjust the width and height of the svg element without any issues. Here is the issue illustrated: Below is the c ...

How to use addclass in AngularJS?

Can someone assist me with converting this to jQuery? $('.toggle').on('click', function() { $('.container').addClass('active'); }); $('.close').on('click', function() { $('.container&ap ...

"webpack" compared to "webpack --watch" produces varying results in terms of output

My project is built on top of this setup: https://www.typescriptlang.org/docs/handbook/react-&-webpack.html Running webpack compiles a bundle that functions correctly in the browser. However, running webpack --watch to recompile on file changes resul ...

Combine an array of objects that are dynamically created into a single object

Having trouble transforming the JSON below into the desired JSON format using JavaScript. Current JSON: { "furniture": { "matter": [ { "matter1": "Matter 1 value" }, { "matter2": "Matter 2 value" }, { ...

Navigate to a specific hidden div that is initially invisible

Currently, I am working on a web chat application using next.js. The app includes an emoji picker button, which, when clicked, displays a menu of emojis. However, the issue I am facing is that the user has to scroll down in order to see the emoji menu. I a ...

Creating distinct web addresses for various sections of vue.js pagination

I've implemented pagination using vue.js for my website's gallery. However, I'm facing an issue where the URL doesn't change when navigating through pages and upon page refresh, it always resets to page 1. My goal is to have the URL ref ...

Error message: Trying to call the prepare() function on a null variable within the CRUD system

I have implemented a CRUD system on my website. The main page (avisos.php) displays a table with all the existing records. When a user clicks on the "ADD NEW RECORD" button, the following script is triggered: $("#btn-add").click(function(){ $(".co ...

What could be causing my React Router to fail in displaying the content of Home.js?

My <Route> is not functioning as expected The Route leading to the homepage does not show the content from the Home.js file import "./App.css"; import Navbar from "./components/Navbar"; import { BrowserRouter as Router, Route, Ro ...

Discovering the data-id value in an HTML element by clicking it with JavaScript and returning that value through a for loop

this is my unique html content <ul class="dialogs"> {% if t_dialogs %} <li class="grouping">Today</li> {% for item in t_dialogs %} <li class=&qu ...

Error message 'Object doesn't have support for this property or method' is triggered by a basic JSON object

Recently, I developed a compact framework for loading resources asynchronously (hyperlink). The framework functions properly in modern browsers such as Opera, Chrome, and Firefox. However, when testing it in IE8, the code fails to execute. Internet Explor ...

The live updates for user data in Firestore are not being reflected immediately when using valueChanges

Utilizing Angular and Cloud Firestore for my backend, I have a setup where users can follow or unfollow each other. The issue arises when the button text and list of followers/following do not immediately update on the front end after a successful click ev ...

Steps to adding a collection of links (stylesheets, javascript files) to each html document

Is it feasible to add a list of links to multiple HTML files? I was inspired by W3 School's W3 Include functionality, which allows you to import blocks of HTML code into various files simultaneously, making it convenient for making changes across many ...

How to automatically open JQuery Accordion panels when the page loads

My Accordion loads with the 1st panel open upon page load, but I am looking for a way to have the entire Accordion closed by default. Any help or suggestions on how to achieve this would be highly appreciated. Thank you for your assistance. FIDDLE http:// ...

Function "Contains" not Present in Object

Upon executing the code provided below, I encounter the following error message. An issue has arisen: Cannot find function contains in object Is Patient Fasting?/# of Hours->Yes; 12 hours. Here is the snippet of my code: var i = 0; var tempF ...

Utilizing React to implement a search functionality with pagination and Material UI styling for

My current project involves retrieving a list of data and searching for a title name from a series of todos Here is the prototype I have developed: https://codesandbox.io/s/silly-firefly-7oe25 In the demo, you can observe two working cases in App.js & ...

Tips on crafting tailored CSS styling for targeted div elements such as before and after:

Looking to style specific div elements with the same class name? <div class="main"> <div class="banner_image"> banner 1</div> <div class="banner_image ">banner 2</div> <div class="banner_image ">banner 3</di ...