【问题标题】:Meteor user profile not being publishedMeteor 用户配置文件未发布
【发布时间】:2014-06-05 11:11:30
【问题描述】:

根据meteor docs,用户个人资料信息总是公开的:

http://docs.meteor.com/#meteor_user

但是,Meteor.user.profile 在我的 Chrome 控制台中是 undefined,但是当我签入 mongodb 服务器端 cli 时,它包含正确的用户数据。

这是我的模板代码:

<head>
  <title>test-login</title>
</head>
<body>
  {{> userInfo}}
</body>
<template name="userInfo">
  {{#if currentUser}}
    {{> userLoggedIn}}
  {{else}}
    {{> userLoggedOut}}
  {{/if}}
</template>
<template name="userLoggedIn">
  {{#if loggingIn}}
    <a>Logging In</a>
  {{else}}
    <a>{{curentUser.profile.name}}</a>
  {{/if}}
</template>
<template name="userLoggedOut">
  <a id="login">Login with Github</a>
</template>

我的客户端js:

Template.userLoggedOut.events({
  "click #login": function (e, tmpl) {
    Meteor.loginWithGithub({
      requestPermissions: ['user', 'public_repo']
    });
  }
});

Template.userLoggedIn.events({
  "click #logout": function (e, tmpl) {
    Meteor.logout();
  }
});

我的服务器端js:

ServiceConfiguration.configurations.remove({
  service: 'github'
});

ServiceConfiguration.configurations.insert({
  service: 'github',
  clientId: 'xxxxxx',
  secret: 'yyyyyyyyyyy'
});

我正在使用最新的流星0.8.0,只有以下软件包:

standard-app-packages
autopublish
insecure
accounts-github
service-configuration

【问题讨论】:

  • 除了@sbking 的解释之外,我遇到的另一个问题是 currentUser 拼写错误

标签: meteor


【解决方案1】:

应该是Meteor.user().profile,而不是Meteor.user.profile

【讨论】:

    猜你喜欢
    • 2015-01-21
    • 1970-01-01
    • 2018-06-22
    • 1970-01-01
    • 1970-01-01
    • 2020-12-11
    • 2017-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多