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

The transformation of a class-based component into a functional one is proving to be ineffective

I am attempting to transform my class-based component into a functional one, but I am struggling with passing two parameters in one onClick function without relying on set state. Additionally, I want to avoid creating multiple extra functions as it would i ...

Verify that a minimum of one checkbox has been ticked according to JavaScript guidelines, with appropriate notifications in case

Need help with displaying a message when no checkbox is checked. Currently implementing JavaScript rules and messages <form method="post" enctype="multipart/form-data name="english_registration_form" id="english_registration_form" > <div cl ...

Retrieve a collection of JSON files using a single function

The format of JSON links is as follows: www.example.com/link-number-end-of-link.com.json I need to retrieve multiple JSON link files where the only variable changing is the number in the link. For example, it could range from 10 to 40, with the first ...

Ways to determine the height of a row within a flexbox

Is it possible to obtain the height of each row within a flexbox container using JavaScript? For instance, if there are 3 rows in the container, can I retrieve the height of the second row specifically? ...

Typescript encounters ERROR TS1128: Expecting a declaration or statement

Having trouble with a TypeScript error in my game-details.component.ts file that I've been trying to fix for a couple of hours. It's showing up at line 26, column 54 and everything seems correct to me. Interestingly, when I press CTRL + S in my ...

The typical initial default argument to be passed to the function using fn.apply

Recently, I discovered the power of using fn.apply() in JavaScript to store function calls with all their arguments intact for future use. In my specific situation, I don't require the first argument, which is the context (this), and I want to find a ...

Contrasting the disparities between creating a new RegExp object using the RegExp constructor function and testing a regular

Trying to create a robust password rule for JavaScript using regex led to some unexpected results. Initially, the following approach worked well: const value = 'TTest90()'; const firstApproach = /^(?=(.*[a-z]){3,})(?=(.*[A-Z]){2,})(?=(.*[0-9]){2 ...

Iterating through an array with ngFor to display each item based on its index

I'm working with an ngFor loop that iterates through a list of objects known as configs and displays data for each object. In addition to the configs list, I have an array in my TypeScript file that I want to include in the display. This array always ...

Unable to render data in Chart JS using PHP JSON

Hello, I’m currently working on creating a dynamic line chart using Chartjs. The data is being pulled from an SQL database using PHP in JSON format. Although the data is successfully retrieved, the chart appears blank. Any assistance would be greatly app ...

The ng-grid in Angular fails to update when changes are made from a modal dialog

There is a form on the page that consists of textboxes and a submit button. Upon entering values in the textboxes and clicking the submit button, a grid is displayed. The grid contains multiple columns with a delete button at the end of each row. Clicking ...

What is the best way to modify the styling of my CSS attributes?

I'm currently working with this CSS code: input:checked + .selectablelabel .check { visibility: hidden; } Now, I want to change the visibility property to "visible" using JavaScript. I attempted the following: $(document).on('click', & ...

What is the best way to assign a value to a button in Ionic/Angular?

Is there a way to bind the name and value attributes to a button? I am facing an issue with this and need a solution. I am attempting to achieve the following: <ion-button type="submit" color="primary" style="text-align:center& ...

What is the best way to add a separator in a b-dropdown menu once the options have been loaded using Vue?

Here is the code snippet for my dropdown element: <b-dropdown id="SchemaDropdown" name="SchemaDropdown" variant="form-control" class="" style="width: 100%" ...

In AngularJs, users can select multiple options using check-boxes, which will automatically generate a tag based on the selected choices. Additionally,

I am looking to implement a feature where users can make multiple selections using checkboxes. Based on their selections, tags will be created using an Angular directive. If a user selects multiple checkboxes, corresponding tags should be generated. If a t ...

How to store angular 2 table information generated using ngFor

I am currently working on a project where I need to create an editable table using data retrieved from the back end. My goal now is to save any updated data. I attempted to use formControl, but it seems to only save the data in the last column. Below is a ...

Increase the value of $index within the ng-repeat loop

Is there a way to increment the value of $index in ng-repeat by a specific amount? For example, if I want to display two values at a time, how can I ensure that the next iteration starts with the third value instead of the second value? <div ng-contr ...

Can you create a stroke that is consistently the same width as the container BoxElement?

Utilizing a BoxElement provided by the blessed library, I am showcasing chat history. New sentences are inserted using pushLine. To enhance readability, days are separated by lines (which are added using pushLine). The width of each line matches that of t ...

Resolving conflicting event handlers within vue.js

I have a situation where I'm trying to use two buttons on a page to navigate to different sections. When I include only one button, everything works fine. But when I include both buttons, only one of them functions properly. Upon debugging, I noticed ...

The functionality of CSS3 animations may sometimes be unreliable following the onLoad event

Here is a snippet of code to consider: $(function() { $('#item').css({ webkitTransform: 'translate(100px, 100px)' }); }); The element I am attempting to move has the following CSS properties: transform: translate3d(0 ...

Error when compiling TypeScript: The callback function provided in Array.map is not callable

This is a Node.js API that has been written in Typescript. app.post('/photos/upload', upload.array('photos', 12), async (req, res) => { var response = { } var list = [] try { const col = await loadCollection(COLLECTION_NAM ...