如何在 ember-simple-auth 中获取当前认证用户的详细信息?

How to get details about the current authenticated user in ember-simple-auth?

我想知道如何获取Ember中当前用户的信息。我正在使用 ember-simple-auth.

我关注了这个 answer 但无法访问 this.get('session.user_email')

但是,如果我在 application.js 路线中执行以下操作:

export default Ember.Route.extend(ApplicationRouteMixin, {
  model() {
    console.log(this.get('session'));
  }
});

我收到以下回复:

这是回购的 link:https://github.com/ghoshnirmalya/hub-client

你有没有在你的路由(或控制器)中注入会话对象

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

或短

session: Ember.inject.service()

完成此操作后,您应该可以在模板中使用它

{{#if session.isAuthenticated}}

或内码:

this.get('session').invalidate();