meteor accounts-github pkg登录后不显示用户名

meteor accounts-github pkg does not display username after logging in

我的流星应用程序中安装了以下软件包:

accounts-github 1.3.0
accounts-password 1.4.0
accounts-ui 1.1.9
github-config-ui 1.0.0

我使用 {{> loginButtons}} 显示登录菜单

如果我使用标准用户名和密码登录,它会在登录后正确显示用户名。如果我使用 github 登录,它会成功登录,但不会显示任何用户名。唯一出现的是下拉箭头。单击它会显示退出按钮。

这是我的帐户配置代码。

Accounts.ui.config({
passwordSignupFields: "USERNAME_AND_EMAIL"
});

如果您需要 user.username 字段作为字段 user.services.github.username[=17 中的 Github 用户名=].您可以在 onCreateUser 函数中执行此操作。

 Accounts.onCreateUser((options, user) => {
    user.profile = options.profile;

    // If signed in with github
    if (user.services.github) {
        user.username = user.services.github.username
    }

    return user;
 });

这段代码应该在服务器端,而不是在 Meteor.startup() 内部。