首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用远程MongoDB登录Keystone

无法使用远程MongoDB登录Keystone
EN

Stack Overflow用户
提问于 2018-12-12 21:02:34
回答 1查看 407关注 0票数 1

我正在尝试使用托管在mLab上的远程数据库服务器来设置keystone项目。我在这里使用这个指南https://itnext.io/building-a-node-cms-with-keystonejs-mongo-db-react-and-redux-part-i-ae5958496df2

我已经用我的mLab数据库url编辑了keystone.init()配置中的mongo URL,并设法运行了项目。

代码语言:javascript
复制
'mongo': 'mongodb://*username*:*password*@ds127624.mlab.com:27624/keystone',

但是,我无法以用户身份登录。

登录页面返回:“您输入的电子邮件和密码无效。”

我需要做更多的配置才能正常工作吗?

……

user.js

代码语言:javascript
复制
var keystone = require('keystone');
var Types = keystone.Field.Types;

var User = new keystone.List('User');

User.add({
  name: { type: Types.Name, required: true, index: true },
  email: { type: Types.Email, initial: true, required: true, index: true },
  password: { type: Types.Password, initial: true },
  canAccessKeystone: { type: Boolean, initial: true },
});

User.register();

0.0.01-admin.js文件

代码语言:javascript
复制
var keystone = require('keystone');
var User = keystone.list('User');

exports = module.exports = function (done) {
    new User.model({
        name: { first: 'admin', last: 'user' },
        email: 'admin@keystonejs.com',
        password: 'admin',
        canAccessKeystone: true,
    }).save(done);

};
EN

回答 1

Stack Overflow用户

发布于 2019-03-05 23:23:57

对于使用密码的远程数据库,您还必须添加authsource选项。基本上就是将?authSource=admin添加到您的mongo url中。admin是缺省数据库,您也可以对其进行更改

mongodb://*username*:*password*@ds127624.mlab.com:27624/keystone?authSource=admin

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53743649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档