【发布时间】:2015-07-04 15:46:35
【问题描述】:
我正在使用user-accounts 包来管理我的应用程序中的帐户系统。
我还集成了 Google、Github、Twitter 和其他第三方服务。
这个包工作正常,但现在我需要为每个用户提供一个特定的页面,对于 SEO 术语,我需要这样的 url:
https://domain.com/user/username
我也有帐户密码包。我已经添加了一个用户名字段,它工作正常。
但是如果使用了第三方服务,弹出窗口会关闭,页面会被重定向,用户创建成功。我读到关于打电话给Accounts.onUserCreate,
这是我的代码:
Accounts.onCreateUser(function(options, user) {
var email = options.profile.email;
var ist = email.indexOf("@");
var uname = email.slice(0,ist);
user.username = uname;
if(options.profile){
user.profile = options.profile;
}
return user;
});
但它给出了一个错误:Cannot read indexOf of undefined.
如何做到这一点?
可以有一个页面,为每个新用户输入用户名,或者这样,电子邮件应该被切片以创建用户名。 (首选第二种方法。)
【问题讨论】:
标签: javascript meteor meteor-accounts