我一直试图找到一个解决方案(遗憾的是现在3个月)使用iOS上的Meteors Accounts Facebook登录Facebook.我已经尝试了谷歌搜索将提出的所有内容,在Meteor论坛上进行了解决,甚至打开了Github问题.
但这个问题仍然逃脱了我.一切都在桌面上工作正常,但是当我在手机上测试时,我收到Facebook错误 "未登录.您尚未登录.请登录并重试".
我已经找到了其他几个有这个问题的人,并且在完整的证据答案上输入很少.在这一点上,我开始变得绝望.
直到Meteor升至1.3之后,这才成为问题.
我已经开始了一个基于meteor样板的min应用程序和模块accounts-ui.
有一个集合创建了调用用户,其中一个元素是profile,这又有一个名为"name"的元素,它获取登录名.
在此测试应用程序中,可以选择更新用户配置文件.更新的数据来自表单提交.我在这里附上了事件监听器
Template.profile.events({
'submit form': function(event) {
event.preventDefault();
var data = SimpleForm.processForm(event.target);
Meteor.users.update(Meteor.userId(), {$set: {profile: data}});
}
});
Run Code Online (Sandbox Code Playgroud)
所以数据包含表格中的所有内容.登录名"name"不包含在表单中,因此也不包含在数据中.
在更新之前,我有users.profile.name - >包含更新后的数据我有users.profile.* - >*等于表单中的所有内容,但"名称"消失了.
最后:谁能保留profile.name字段?最后,我喜欢在users.profile中从PLUS中提取"名称"字段.
感谢任何暗示,因为你读到我是流星的新手 - 并尝试理解事物是如何联系在一起的.
迈克尔
我正在使用Meteor的帐户-ui.有没有办法检查用户是否登录模板而不编写自定义帮助程序代码?
伪代码:
{{#if userIsLoggedIn }}
You're logged in
{{/if}}
Run Code Online (Sandbox Code Playgroud)
如果没有,那么最干净,最惯用的方式是什么?
我在这里只关心客户端.
谢谢.
我正在使用Accounts.createUser()创建新用户,如果您没有做任何花哨的事情,它会正常工作.但我想向新用户添加一些未在文档中列出的其他字段.这是我的代码:
var options = {
username: "funnyUserNameHere",
email: "username@liamg.com",
password: "drowssap",
profile: {
name: "Real Name"
},
secretAttribute: "secretString"
};
var userId = Accounts.createUser(options);
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我已将secretAttribute添加到我的选项对象中.因为没有记录,所以不公平地说它不是在用户对象下添加我的属性.
所以我用谷歌搜索并发现这样的东西可能会起作用:
Accounts.onCreateUser(function(options, user) {
if (options.secretAttribute)
user.secretAttribute = options.secretAttribute;
return user;
});
Run Code Online (Sandbox Code Playgroud)
是的!这是有效的,但总有BUTT ..*但是......在这之后,它不再在用户对象下保存配置文件.然而,这使它工作:
Accounts.onCreateUser(function(options, user) {
if (options.secretAttribute)
user.secretAttribute = options.secretAttribute;
if (options.profile)
user.profile = options.profile;
return user;
});
Run Code Online (Sandbox Code Playgroud)
那么我想要你们呢?
ps:我认为很明显为什么我不想保存配置文件下的所有额外字段;)
我正在制作一个基于服务的dockerized应用程序.有些服务将用流星写,有些则不会.
其中一项服务是注册服务,用户可以在该服务中注册该平台.
在做微服务时,通常我会做以下事情:
var MyService = DDP.connect(service_url);
var MyOtherService = DDP.connect(other_service_url);
var RegistrationService = DDP.connect(registration_service_url);
Run Code Online (Sandbox Code Playgroud)
我想要做的是使用该loginWithFacebook方法.问题是Meteor.loginWithFacebook在前端使用将在主前端服务器上调用其后端方法.
但是,我想在RegistrationService服务器(具有相关包)上调用其后端方法.原因是因为我使用Accounts.onCreateUser钩子做额外的东西,还因为我想保持注册服务与前端分开.
为了清楚起见,即使它不正确,想象一下我有这个:
'click #facebook-login': function() {
Meteor.loginWithFacebook(data, callback)
}
Run Code Online (Sandbox Code Playgroud)
但是,我希望该loginWithFacebook方法RegistrationService 在调用客户端方法.loginWithFacebook时使用服务器端方法,所以我实际上想要做一些事情来实现以下效果:
'click #facebook-login': function() {
RegistrationService.loginWithFacebook(data, callback)
}
Run Code Online (Sandbox Code Playgroud)
任何有关这方面的帮助将不胜感激.谢谢!
我想知道是否有人能够提供一个meteorpad或代码示例,在Meteor中正确使用上面列出的方法之一(使用铁:路由器).我很难理解这些方法究竟是如何与我的应用程序交互的,而且看起来这些方法已经足够新,以至于没有很多关于如何正确使用它们的良好文档.谢谢!
对于Accounts.forgotPassword()和Accounts.sendVerificationEmail(),生成令牌.
该令牌是否会过期?
如果是这样,经过一段时间?
我正在将我的Meteor应用程序从Meteor 1.2迁移到Meteor 1.3,并按照http://guide.meteor.com/methods.html#validated-method上的指南创建一个经过验证的方法.
当我调用该方法时,我认为客户端模拟正在发生,因为我可以注销到控制台,但总是会出现错误Method '...' not found.
/imports/ui/pages/register.js
import {Meteor} from 'meteor/meteor';
import {Template} from 'meteor/templating';
import {FlowRouter} from 'meteor/kadira:flow-router';
// Methods
import {createAccount} from '/imports/api/accounts/methods.js';
// HTML
import './register.html';
Template.Register_page.events({
'submit form': function(event) {
event.preventDefault();
var user = {
email: $('#email').val(),
password: $('#password').val(),
profile: {
firstName: $('#firstName').val(),
lastName: $('#lastName').val()
}
};
createAccount.call(user, function(err) {
if (err) {
console.error(err);
} else {
console.log('User successfully registered');
FlowRouter.go('Dashboard');
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
/imports/api/accounts/methods.js
import {Meteor} from 'meteor/meteor';
import …Run Code Online (Sandbox Code Playgroud) 我试过寻找一个答案,但似乎无法让这个工作.我正在使用Meteor与Cordova构建移动应用程序.
我想为我的Users集合添加一个属性(Meteor在我登录时创建的属性).即.例如,我想将{currentHotel:"Something"}添加到我的db.Users集合中.
我正在尝试以正确的Publish - Subscribe方式执行此操作.使用Meteor.methods被引用对实时应用程序不利.无论哪种方式,我想了解如何使用Publish - Subscribe更新Users集合.
//On the server, I did
Meteor.publish("userData", function () {
return Meteor.users.find({_id: this.userId},
{fields:{services: 1, currentHotel: 1}});
});
Run Code Online (Sandbox Code Playgroud)
因此,客户端应该可以访问currentHotel字段.现在更新"currentHotel"字段:
//On the client I do
Meteor.subscribe('userData');
var user = Meteor.users.findOne({"_id": Meteor.userId()});
Meteor.users.update({_id: user._id}, {$set:{currentHotel:'something'}});
//I tried this too
//Meteor.users.update({ _id: Meteor.userId() }, {$set: });
Run Code Online (Sandbox Code Playgroud)
在浏览器控制台上,我可以看到"currentHotel"和"services"就好了,这意味着发布 - 订阅工作正常.但我似乎无法更新currentHotel.我得到一个拒绝访问.为什么是这样?
此外,如果Collection中根本不存在"currentHotel"属性,我如何使用类似的发布 - 订阅添加它?我是否可以发布不存在的属性并允许客户订阅并添加该属性?
我提到了Meteor文档,这个,这个和这个,但似乎仍然无法让它工作!:-(
提前致谢!
collections publish-subscribe mongodb meteor meteor-accounts
meteor ×10
meteor-accounts ×10
javascript ×3
mongodb ×2
collections ×1
facebook ×1
iron-router ×1
kadira ×1
meteor-blaze ×1