mardi 19 juillet 2016

ember get current user information from session

I am using ember-simple-auth library. I was successfully able to logged in a user. But can't able to access current user. The following code is working:

    
      <p>i m logged in</p>
      <a href="#" >Logout</a>
    
      <p>i m not logged in</p>
    

but the following code is not working



I wanted to get user information but failed. So, I dig into the mater and used ember helper as:

<p></p>

It helped me and I was able to get current user information like:

<p></p>

which is good but I want something like the following:

<p></p> 

or simply:

<p></p>

how can I change my application controller so that will be able to get simple current user method which will look good. My application controller code looks like that:

// /app/controllers/application.js

import Ember from 'ember';

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

  actions: {
    logout() {
      this.flash.success('Successfully logged out!', 5000);
      this.get('session').invalidate();
    }
  }
});




Aucun commentaire:

Enregistrer un commentaire