我刚刚开始使用 SocketStream。(v0.1.0) 我用exports.actions.login 函数创建了文件/app/server/auth.coffee。我想访问此文件中的@session.setUserId,但我很难弄清楚@session 的位置以及如何在 /app/server/app.coffee 之外访问它
这是我的 auth.coffee,其中包含我想访问会话的评论。
users = [
username: 'craig'
password: 'craig',
username: 'joe'
password: 'joe',
]
authenticate = (credentials, cb) ->
user = _.detect users, (user) ->
user.username == credentials.username and user.password == credentials.password
authenticated = true if user?
callback cb, authenticated
exports.actions =
login: (credentials, cb) ->
authenticate credentials, (user) ->
# here is where i'd like to set the userId like so:
# @session.setUserId credentials.username
callback cb user