javascriptember.jsauthenticationember-simple-auth

'ApplicationRouteMix' is defined but never used [Ember.js]


I am creating an authentication to login to my app, but I am with these 3 problems and I do not know how to proceed, I am new to ember, I do not know much about how to fix problems, I am learning it yet, after I followed this process my app does not appear anymore the screen went blank only, the tutorial is that of ember-simple-auth: http://ember-simple-auth.com/ - thank you in advance:

Could not start watchman
Visit https://ember-cli.com/user-guide/#watchman for more info.
Livereload server on http://localhost:49153
'instrument' is imported from external module 'ember-data/-debug' but 
never used

/home/carlos/www/vendasapi-frontend/app/controllers/login.js
4:31  error  'session' is not defined  no-undef

✖ 1 problem (1 error, 0 warnings)


/home/carlos/www/vendasapi-frontend/app/routes/application.js
2:8   error  'ApplicationRouteMix' is defined but never used  no-
unused-vars
5:35  error  'ApplicationRouteMixin' is not defined           no-undef

✖ 2 problems (2 errors, 0 warnings)


Build successful (4688ms) – Serving on http://localhost:4200/



Slowest Nodes (totalTime => 5% )              | Total (avg)         
----------------------------------------------+---------------------

Babel (20)                                    | 1481ms (74 ms)      
Rollup (1)                                    | 1352ms              
EslintValidationFilter (2)                    | 703ms (351 ms)      
Concat (8)                                    | 545ms (68 ms)       

app/controllers/login.js

import Ember from 'ember';

export default Ember.Controller.extend({
session: Ember.inject.service(session),

  actions: {
    authenticate() {
  let { identification, password } = 
this.getProperties('identification', 'password');

   this.get('session').authenticate('authenticator:oauth2', 
identification, password).catch((reason) => {
     this.set('errorMessage', reason.error);
      });

    }

  }

});

app/controllers/application.js

import Ember from 'ember';

export default Ember.Controller.extend({
  session: Ember.inject.service('session'),

   actions: {
     logout() {
      this.get('session').invalidate();
   }
 }
});

app/routes/application.js

import Ember from 'ember';
import ApplicationRouteMix from
'ember-simple-auth/mixins/application-route-mixin';

export default Ember.Route.extend(ApplicationRouteMixin);

Solution

  • The console output literally spell the problems:

    You have session: Ember.inject.service(session) there. But there's no session variable defined so you cannot call Ember.inject.service on it... What you need here is just:

    session: Ember.inject.service('session') or even:

    session: Ember.inject.service()

    It says that on line 2 you're importing as ApplicationRouteMix but you're never using that anywhere. And then on line 5 that you're using ApplicationRouteMixin but haven't defined it anywhere. That's just because you have a typo - what you want to use is:

    import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';