标签: meteor-accounts

流星中的resetPassword问题

我向用户发送了注册电子邮件,当他输入密码和其他详细信息时,我正在尝试重置密码,但是它正在抛出错误

uncaught error extpected to find a document to change
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

正如你在法师中看到的那样

我订阅了用户记录

我的代码

this.route('enroll', {
        path: '/enroll-account/:token',
        template: 'enroll_page',
        onBeforeAction: function() {
            Meteor.logout();
            Session.set('_resetPasswordToken', this.params.token);
            s = this.subscribe('enrolledUser', this.params.token).wait();
        }
    }),
Run Code Online (Sandbox Code Playgroud)

在我显示表单和提交事件之后

onSubmit: function(creds) {
            var options = {
                _id: Meteor.users.findOne()._id,
                name: creds.name
            }
            var token=Session.get('_resetPasswordToken');
            Meteor.call('updateUser', options, function(error, result) {
                if(!error) {
                    Accounts.resetPassword(token, creds.password, function(error) {
                        if (error) {
                            toastr.error("Sorry we could not update your password. Please try again.");
                            return false;
                        }
                        else{
                            toastr.error("Logged In");
                            Router.go('/');
                        }
                    });
                } …
Run Code Online (Sandbox Code Playgroud)

meteor meteor-accounts

4
推荐指数
1
解决办法
954
查看次数

自定义Meteor注册模板

在我的应用程序中,我想为用户播种数据库并向他们发送注册链接以激活他们的帐户(并选择密码).我还希望他们验证/更改一些配置文件数据.

在服务器上我按如下方式为数据库播种:

Meteor.startup(function () {
  if(Meteor.users.find().count() === 0) {
    var user_id = Accounts.createUser({ email: 'some@email.com', profile: { some: 'profile' } });
    Accounts.sendEnrollmentEmail(user_id);
  }
})
Run Code Online (Sandbox Code Playgroud)

注册链接按预期发送,但我想为单击电子邮件中的URL时创建自定义模板.最好由铁路由器处理.(不使用accounts-ui包).

我尝试过将用户重定向到这样的自定义路线:

var doneCallback, token;

Accounts.onEnrollmentLink(function (token, done) {
  doneCallback = done;
  token = token;
  Router.go('MemberEnroll')
});
Run Code Online (Sandbox Code Playgroud)

哪个不起作用(它改变了网址但没有渲染我的模板)

我还尝试更改服务器上的注册URL,如下所示:

Accounts.urls.enrollAccount = function (token) {
  return Meteor.absoluteUrl('members/enroll/' + token);
};
Run Code Online (Sandbox Code Playgroud)

但是当我这样做时,Accounts.onEnrollmentLink回调不会触发.此外,更改URL没有记录,所以我不确定它是一个好的做法.

任何帮助表示赞赏.

meteor iron-router meteor-accounts

4
推荐指数
1
解决办法
1811
查看次数

用户电子邮件未显示在模板[METEOR]中!

我有一个用户索引,并希望显示每个用户的信息.用户ID显示正常,但应用程序未显示电子邮件.

这是我的模板:

<template name="users">
  <h1>List of all users</h1>
  {{#each users}}
    <div class="list_item">
      <p>ID: {{_id}}</p>
      <p>Email: {{email}}</p>
    </div>
  {{/each}}
</template>
Run Code Online (Sandbox Code Playgroud)

以下是我的路线:

Router.route('/users', function () {
  this.render('users');
}, {
  waitOn: function() {
    return [
      Meteor.subscribe('users')
    ]
  },

  data:  {users: Meteor.users.find({})}
});
Run Code Online (Sandbox Code Playgroud)

最后,我的出版物:

Meteor.publish('users', function () {
  return Meteor.users.find({}, {fields: {emails: 1, profile: 1}});
});
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

meteor meteor-accounts

4
推荐指数
1
解决办法
753
查看次数

Meteor从userId获取用户名,更简单的方法

使用流星:

我在Messages中有一个消息列表,用于存储userId.

Messages = new Mongo.Collection('messages'); 

// example of message data:

{
authorId: 'XFdsafddfs1sfd', // corresponding to a Meteor.userId
content: 'some Message'
}
Run Code Online (Sandbox Code Playgroud)

我正在发布消息和现有用户.

Meteor.publish('messages', function () {
  return Messages.find({});
});

Meteor.publish('users', function () {
  return Meteor.users.find({});
});
Run Code Online (Sandbox Code Playgroud)

目前,我可以获取消息列表并根据userIds添加用户名.由于用户可以更改其用户名和配置文件信息,因此将用户数据添加到集合中只是userIds是没有意义的.

var messages = Messages.find({}).fetch();
var messages.forEach(function(message) {
    message.username = Meteor.users.find(message.authorId).fetch() [0].username; // ugly
  });
Run Code Online (Sandbox Code Playgroud)

此代码有效,但涉及大量浪费的调用.我想知道如何以更好的方式实现这一目标.

在Meteor中,将用户数据与包含userIds的集合配对的最有效和最干净的方法是什么?

meteor meteor-accounts

4
推荐指数
1
解决办法
2369
查看次数

Meteor - 为什么我应该尽可能使用this.userId而不是Meteor.userId()?

从David Glasser在GitHub问题上的评论来看:

this.userId是主要的API,Meteor.userId()对于刚接触JavaScript的用户来说是语法糖,他们可能还不了解成功使用它的细节

似乎我们应该this.userId尽可能使用(例如在方法函数中,你可以使用它们),并且只使用Meteor.userId()内部发布函数.如果这个假设是正确的,为什么

(参考代码的相关位也会有所帮助,我似乎无法找到它)

javascript mongodb meteor ddp meteor-accounts

4
推荐指数
1
解决办法
1552
查看次数

在Meteor中通过短信登录和注册过程

我需要在我的Meteor应用程序中进行SMS身份验证.

假设我有一个简单的形式(在React风格中,因为我在前端使用React):

<form onSubmit={ this.submitPhone() }>
  <input type='text' size='10' placeholder='Your phone here' />
  <input type='submit' value='Send me a code'/>
</form>
Run Code Online (Sandbox Code Playgroud)

用户输入他的电话号码并提交表格.之后,将SMS代码发送到输入的号码.并出现一个新表格:

<form onSubmit={ this.submitCode() }>
  <input type='text' size='5' placeholder='Enter code' />
  <input type='submit' value='Sign In'/>
</form>
Run Code Online (Sandbox Code Playgroud)

如果用户正确输入了他的代码,那么Meteor应该知道用户已登录(我认为有一些_id).如果代码不正确,则会显示错误消息.

我发现Twilio服务和这个,看起来它正是我需要的.但我根本不知道如何使用它.

几个月前我在教程中尝试过Meteor的默认Accounts UI方式,但实际上我不知道如何做这些事情,尤其是通过短信.我不需要像我的应用程序中的角色这样的东西,我甚至不需要用户名,密码和电子邮件.我只需要有一个用户基础_idphone.所以我需要的是让用户能够登录(第一次登录是以这种方式注册).

感谢您的帮助,这次我需要一个详细的答案.

authentication login twilio meteor meteor-accounts

4
推荐指数
1
解决办法
866
查看次数

Meteor如何访问服务器和客户端的Facebook Graph Api

accounts-facebook包仅提供logIn和logOut功能.

meteor-fbgraph可以访问服务器端的fbgraph.

facebook-sdk可以在客户端访问fbgraph.

问题是facebook-sdk不使用Accounts-ui提供的任何东西,例如Accounts.onLoginevent或Accounts.ui.config.点击{{> loginButtons}}用户登录后只Meteor.user()注销,facebook-sdk仍然有它的AccessToken并保持登录状态.结果一半的应用程序仍然登录(客户端),一半注销(服务器).

这是我的帐户与FB事件配对的解决方法,但我认为这不是一个合适的解决方案.

Accounts.onLogin(function(){
  FB.login();
  AccountsOnLogout(function(){
    FB.logout();
  });
});

function AccountsOnLogout(callback){
  var waitForLogout = setInterval(function() {
    if (!(Meteor.user())) {
      console.log("logged out");
      callback();
      clearInterval(waitForLogout);
    }
  }, 1000);
}
Run Code Online (Sandbox Code Playgroud)

你有更好的想法如何在客户端获得fbGraph吗?

javascript facebook-graph-api meteor meteor-accounts

3
推荐指数
1
解决办法
1559
查看次数

Meteor帐户 - 自定义登录页面

在Meteor中,我使用基于帐户的插件进行身份验证系统.现在,我需要创建自定义登录页面,我该如何实现呢?

html login meteor meteor-accounts

3
推荐指数
1
解决办法
2396
查看次数

向集合中的当前文档添加新字段时,Meteor.users.update访问被拒绝

我想在当前文档中添加一个新字段(将来会用$ push填充的数组)但是我收到了错误 update failed: MongoError: Cannot apply $push/$pushAll modifier to non-array

我正在研究Meteor.users集合.

代码运行是:

var user = Meteor.userId();
Meteor.users.update({_id:user}, {$set: {"newfield": ["some data"]}});
Run Code Online (Sandbox Code Playgroud)

mongodb meteor mongodb-update meteor-accounts

2
推荐指数
1
解决办法
3388
查看次数

在打字稿中使用 matb33:collection-hooks

我正在创建一个 Angular2-Meteor 应用程序,从社交教程开始。我正在尝试使用 alanning:roles 和 matb33:collection-hooks 实现用户角色。该解决方案与此处提出的解决方案类似。唯一的区别是 Angular 2 需要角色和 Collection-Hooks 的打字稿定义。我找到了meteor-typescript-libs,它有一个似乎有效的角色定义。然而,我发现的唯一的 collection-hooks 资源是 typed-meteor-collection-hooks。我尝试通过将文件复制/粘贴到我的项目中来引用index.d.ts,但仍然收到以下错误:

server/imports/accounts.ts (30, 14): 类型“Collection < User >”上不存在属性“after”。

在下面一行:

Meteor.users.after.insert(function (userId, doc) {    
if (doc.profile.type === "basic") {
    Roles.addUsersToRoles(doc._id, [ROLES.Basic])
} else if (doc.profile.type === "admin") {
    Roles.addUsersToRoles(doc._id, [ROLES.Admin])
} else if (doc.profile.type === "manager") {
    Roles.addUsersToRoles(doc._id, [ROLES.Manager])
}});
Run Code Online (Sandbox Code Playgroud)

我是打字稿新手,我不清楚应该如何实现 Meteor 包的类型定义。显然,我的做法是错误的。有人对 Meteor-Angular2 中的角色和收集挂钩有任何经验吗?

更新:尽管出现错误,但似乎 Meteor.users.after.insert() 代码在插入用户后正在执行。我正在继续开发,但希望有一个消除错误的解决方案。

typescript meteor-accounts angular2-meteor

2
推荐指数
1
解决办法
305
查看次数