0

When I first do a login, and set some props to this.get('session'), everything works fine. Code below:

  actions: {
// display an error when authentication fails
authenticate: function() {
  var _this = this;
  var credentials = this.getProperties('identification', 'password');
  this.get('session').authenticate('authenticator:custom', credentials).then(
  function() {
    var username = _this.get('session.secure.data.name');
    //look here, I set a username props to session object
    _this.get('session').set('username', username);
    //debugger;
  }, function(message) {
    // but the reject callback works fine, the message is the right one
    _this.set('errorMessage', message.msg);
    _this.set('identification', '');
    _this.set('password', '');
  });
 }
}

and the hbs below

{{#if session.isAuthenticated}}
  Hi,{{session.username}}
{{else}}
{{#link-to 'login'}} Login {{/link-to}}
  or
{{#link-to 'signup'}} Signup {{/link-to}}
{{/if}}

everything works fine for now, but after I refresh the page

{{session.username}} is undefined,

How can I solve this?

Thx

SteveFerg
  • 3,466
  • 7
  • 19
  • 31
vikingmute
  • 412
  • 2
  • 10
  • 24

0 Answers0