Activating view loading in AngularJS through child window authentication (OAuth)

I have tried implementing OAuth in AngularJS using Hello.js following what I believe is the best practice. However, I am encountering some issues with my current approach as described below:

After injecting Hello.js into Angular and setting up the OAuth popup window for Google+ in my controllers.js file, I encountered a problem with the routing when redirecting from the child window to the parent window.

  hello.init({
        google: MY_APPLICATION_ID
    },{redirect_uri:'app/_partials/'});

     $scope.doLogin = function(network) {
         console.log('Calling hello ' + network);
         hello.login(network,function(r){ // callback
            console.log("login successful..");
         });
     };

It seems that the redirect doesn't work properly due to issues with the $routerProvider in Angular. To bypass this, I had to use a temporary "fake" index.html view.

My route configuration looks like this:

    $routeProvider.
        when("/userLogin", {templateUrl: "_partials/userLogin.html", controller: "webClientController"})
        .when("/dialInterface", {templateUrl: "_partials/dialInterface.html", controller: "webClientController"})
        .when("/error404", {templateUrl: "_partials/error404.html", controller: "webClientController"})
        .otherwise({redirectTo: '/error404'});

To manage the redirect issue, I used jQuery in the fake index.html:

<!-- temp workaround to manage oAuth since routeProvider doesn't match the REDIRECT URI correctly -->

<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
    $("#go-to-dial-interface",opener.document).trigger('click');
    window.close();
</script>

The content of /userLogin view:

<md-content class="md-padding md-primary" style="height: 600px;padding: 24px;" layout-fill>
    <a ng-click="doLogin('google')" class="zocial googleplus">Sign in with Google+</a>
</md-content>


<a id="go-to-dial-interface" href="#dialInterface" style="visibility:hidden;"></a>

The flow of logic (and the problem faced) is outlined as follows:

  1. User clicks on the anchor tag triggering doLogin('google') function in the controller
  2. Google account is selected leading to a redirect to the fake index.html
  3. Index.html loads in the OAuth popup and executes script successfully but fails to trigger a redirect to #dialInterface
  4. Current view is reloaded without transitioning to the new view as expected

If you have any suggestions or improvements to offer, they would be greatly appreciated. Thank you for your assistance.

Answer №1

Is the webClientController already prepared for the /dialInterface page? Have any errors appeared in the console?

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

Are you currently working on a Ruby on Rails application?

Seeking guidance from the StackOverflow community on best practices when taking over a Rails app from another developer. I am stepping into a new role as the lead developer at my workplace. While I have experience in front-end, SQL/Mongo, Node.js, and kno ...

`Where can I locate a grid example?`

Right here: Upon reading the documentation, I discovered: onItemInserting has the following arguments: { grid // represents the grid instance item // item being inserted } In my software application there are multi ...

Top strategy for monitoring a user's advancement in reading different text segments

If you are familiar with zyBooks, I am looking to implement a similar feature where users can track the sections they have read and mark them as completed with a button. However, I am struggling conceptually with determining how best to structure my mongo ...

Utilizing Javascript to filter data across multiple columns in tables

I've been experimenting with the JavaScript code below to filter table rows. The original code is from w3schools, but I made some modifications to target all input values. It works well for filtering one column, however, when I try to input a value in ...

Issue encountered during creation of a polyline in Cesium

When attempting to create a polyline in my ReactJs app using the code below, I encountered an error message stating "DeveloperError: Expected value to be greater than or equal to 0.0125, the actual value was 0." Can someone shed some light on why this er ...

Insert a scrollbar into the new popup window on Internet Explorer after the window has been opened

I am looking to enable scrolling in a pop-up window after it has been opened. While FireFox offers the 'window.scrollbars' property for this, Internet Explorer does not have a similar feature. Is there a way to add scrolling functionality in IE u ...

Looking for a way to limit the number of characters allowed per line in a textarea using jQuery

I have the following HTML textarea: <textarea name="splitRepComments" cols="20" rows="3" ></textarea> I have implemented a maxlength restriction using jQuery with the following function: var max = 100; $('#splitRepComments').bind(" ...

Steps to automatically populate the dropdown upon page load

Hello, I have a question regarding setting a value to a dropdown list in JavaScript. Currently, I am trying to execute this function during the onload event of the body tag. However, I am facing issues with setting the value. Below is the code: function s ...

Using jQuery and AJAX to fetch the return value of a PHP class method

Starting a new project for myself has been quite the learning experience. As someone who isn't the most skilled programmer, I decided to kick things off in PHP. However, I quickly realized that executing PHP functions and class methods through HTML bu ...

The React DOM isn't updating even after the array property state has changed

This particular issue may be a common one for most, but I have exhausted all my options and that's why I am seeking help here. Within my React application, I have a functional component named App. The App component begins as follows: function App() ...

Guide to switch background image using querySelector

I am currently trying to figure out how to set the background image of a div block by using querySelector. I have attempted various methods in my test code below, but unfortunately none seem to be working. Can someone please provide assistance? <!DOC ...

Applying a class change in Vue.js upon mounting

How can I make a button element with a .hover property trigger the hover animation as soon as the page loads? I want to apply a class to the button when the page is mounted and then remove it later. What is the best approach for this? I considered using a ...

Exploring the capabilities of dynamic pathname routing in Next.js

Consider this scenario: there is a path that reaches me as /example/123 and I must redirect it to /otherExample/123. My code utilizes next/router, extracting the URL from router.asPath. if(router.asPath == '/example/123') { Router.push(' ...

Enhance videojs player source with personalized headers

Currently, I have a backend API running on Express that manages a streaming video m3u8 file. The endpoint for this file is: http://localhost:3000/api/stream.m3u8 It is important to note that access to this endpoint requires a valid user token. router r ...

What could be causing the routing to fail in this script?

Currently working on a small project to dive into AngularJS, and I'm facing some challenges with getting the routing to function properly. Despite following numerous tutorials, my code doesn't seem to be working as expected. If anyone could lend ...

Tips for escaping an infinite loop within the componentDidUpdate function in reactjs

Currently, I am working on creating dashboards using reactjs. I have successfully implemented 4 tabs or buttons for charts, but I am facing an issue when clicking on different dashboards that have the same chart in the same panel. The chart is not updating ...

What is the correct way to store user input in the "store" using vuex.js? Can you help me identify where I went wrong?

On the third day of my suffering, I seek your help. Can you please guide me on how to save text input in "store" in vuex.js and then add it to the value of the same input itself? I've attempted it like this but seem to be making a mistake somewhere. ...

Utilize JQuery variables for toggling the visibility of various DIV elements

On my webpage's splash page, there are 4 divs but only the home div is initially visible. The other three are hidden. Each of these divs has a button associated with it that triggers a jquery click event to swap out the currently visible div for the ...

Is this example showcasing the use of JavaScript closures?

I have a JavaScript query that may be geared towards beginners: var countries = [ "Bangladesh", "Germany", "Pakistan"]; function checkExistence(arr, input) { for (var i = 0; i < arr.length; i++) { if (arr[i] != input) { a ...

Route.get() is looking for a callback function, but instead received an [object Promise]

Currently, I am in the process of developing a REST API using express and following the architecture outlined in this particular article. Essentially, the setup involves a router that calls a controller. Let me provide you with an example of how a call is ...