使用SailsJS在PostgreSQL中连接会话 [英] Connect session in PostgreSQL with SailsJS

查看:256
本文介绍了使用SailsJS在PostgreSQL中连接会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SailsJS,Passport-Local和PostgreSQL中有一个个人项目。我设法获得连接并将用户保存在PostgreSQL DB中。但是我在会话存储方面有很大的问题。据我所知SailsJS正在使用Connect来完成它。

I have a personal project in SailsJS, Passport-Local and PostgreSQL. I managed to get connection and save users in PostgreSQL DB. But I have big problem with session storing. From what I know SailsJS is using Connect to get it done.

MongoDB的先前工作代码:

Previous working code for MongoDB:

connections: {
    prodMongodbServer: {
        adapter: 'sails-mongo',
        host: 'localhost',
        port: 27017,
        //user: '',
        //password: '',
        database: 'sails-auth'
    }
},

session: {
    adapter: 'mongo',
    host: 'localhost',
    port: 27017,
    db: 'sails-auth',
    collection: 'sessions'
}

我与PostgreSQL的(有效)连接:

My (working) connection to PostgreSQL:

connections: {
    somePostgresqlServer: {
      adapter: 'sails-postgresql',
      host: 'localhost',
      port: 5432,
      user: 'postgres',
      password: 'Password1',
      database: 'sails-auth'
    }
},

我有问题的代码:

session: {
    adapter: 'connect-pg-simple',
    host: 'localhost',
    port: 5432,
    user: 'postgres',
    password: 'Password1',
    db: 'sails-auth'
}

我已经安装了 connect-pg-simple ,已执行SQL代码但是当我启动Sails应用程序时,出现错误:

I've installed connect-pg-simple, executed SQL code but when I am starting sails app I get an error:

$ sails lift

info: Starting app...

Init Express midleware
Failed to prune sessions: password authentication failed for user "myPcUser"
info:
info:                .-..-.
info:
info:    Sails              <|    .-..-.
info:    v0.11.3             |\
info:                       /|.\
info:                      / || \
info:                    ,'  |'  \
info:                 .-'.-==|/_--'
info:                 `--'-------'
info:    __---___--___---___--___---___--___
info:  ____---___--___---___--___---___--___-__
info:

我认为这可能是更好地使用 connect-pg ,但是它需要太多的依赖,以至于我坚持使用简单的版本。有人知道这个问题是什么吗?我在Windows上,所以很奇怪,它对我的​​PC用户来说有问题...

I thought that it may be beetter to use connect-pg, but it requires so many dependecy that I stayed with simple version. Anyone know what this problem is about? Im on windows so its weird that it have problem with my PC User...

或者也许有人有一些解决方案,可将PostgreSQL用于用户等,而将Mongo用于会话。对于我测试过的内容,Passport不允许这样做(用户可以注册,但无法登录)

Or maybe someone have some solution for using PostgreSQL for users, etc and Mongo for sessions. For what I've tested Passport doesnt allow to do that (user can sign up but can't sign in)

推荐答案

也许您可以解决此错误,以打开PostgreSQL客户端身份验证配置文件:

/var/lib/pgsql/data/pg_hba.conf

Perhaps you can fix this error open PostgreSQL client authentication configuration file: /var/lib/pgsql/data/pg_hba.conf

并更改:

本地所有信任

托管所有127.0.0.1/32信任

host all 127.0.0.1/32 trust

保存并关闭文件。重新启动Postgresql服务器:

Save and close the file. Restart Postgresql server:

服务postgresql重新启动

service postgresql restart

这篇关于使用SailsJS在PostgreSQL中连接会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆