Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Infinite loop when accessing /login (using generator-angular-fullstack v3.7.5) #152

Open
rondanal opened this issue Jun 11, 2016 · 2 comments

Comments

@rondanal
Copy link

rondanal commented Jun 11, 2016

Hi,

Apologies for my ignorance here - I'm trying to follow the AngularJS + Yeoman Guide and am experiencing an infinite loop when building the login form section.

I created a new project using generator-angular-fullstack v3.7.5

The generated login.js file for the login route is:

'use strict';

angular.module('testApp')
  .config(function ($stateProvider) {
    $stateProvider
      .state('login', {
        url: '/login',
        template: '<login></login>'
      });
  });

login.controller.js:

'use strict';
(function(){

class LoginComponent {
  constructor() {
    this.message = 'Hello';
  }
}

angular.module('testApp')
  .component('login', {
    templateUrl: 'app/login/login.html',
    controller: LoginComponent
  });

})();

app.js:

'use strict';

angular.module('testApp', ['testApp.constants', 'ngCookies', 'ngResource', 'ngSanitize',
    'btford.socket-io', 'ui.router', 'ui.bootstrap', 'stormpath', 'stormpath.templates'
  ])
  .config(function($urlRouterProvider, $locationProvider) {
    $urlRouterProvider.otherwise('/');

    $locationProvider.html5Mode(true);
  })

  .run(function($stormpath){
    $stormpath.uiRouter({
      loginState: 'login', 
      defaultPostLoginState: 'main' 
    });
  });

I see that these differ from the dashboard-app example code, which doesn't use the component sytnax.
When I run the project and visit `/login' I see an infinite loop in the browser. I've followed all of the steps up to https://docs.stormpath.com/angularjs/guide/register.html#create-the-registration-form verbatim.

Does the most recent version of stormpath-sdk-angularjs support the component style generated here (by generator-angular-fullstack v3.7.5)? If not, is there a easy way to fix the generated code, or would I need to use an older version of generator-angular-fullstack (the tutorial does not specify a version as far as I can tell)?

Thanks

@robertjd
Copy link
Member

Hello @rondanal , thanks for the report. Can you take a look at #147 to see if this is the same issue that you are having? Thanks!

@rondanal
Copy link
Author

Hi @robertjd , thanks for your response.

It looks like it wasn't related to #147, but is now working after modifying a few lines of code in the generator-angular-fullstack v3.7.5 server files.

The first issue seemed to be that I inited the Stormpath middleware after require('./routes').default(app);. I moved this line after the SP init, and also changed the init code from:

app.use(ExpressStormpath.init(app,{
  website: true,
  web: {
    spaRoot: path.join(__dirname, '..','client','index.html')
  }
}));

to the snippet from the dashboard-app example:

app.use(ExpressStormpath.init(app,{
  web: {
    produces: ['application/json'],
    spa: {
      enabled: true,
      view: app.get('appPath')
    }
  }
}));

I also had to modify appPath in the expres.js config file to match the dashboard-app example code. Lastly, in routes.js I modified the now default:

  app.route('/*')
    .get((req, res) => {
      res.sendFile(path.resolve(app.get('appPath') + '/index.html'));
    });

to:

app.route('/*')
    .get((req, res) => {
      res.sendFile(path.resolve(app.get('appPath')));
    });

Everything is now running smoothly.
Thanks!

@rondanal rondanal changed the title Infinite loop when accessing /login Infinite loop when accessing /login (using generator-angular-fullstack v3.7.5) Jun 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants