【发布时间】:2019-07-14 19:11:55
【问题描述】:
我正在开展一个项目,其中有三个公司(即 compA、CompB、compC)。 每个公司都有自己的用户。 这是我的用户架构,用户可以与特定公司相关联
const UserSchema = new Schema({
name:{
type: String,
required: true
},
company:{
type: String,
required: true
},
password:{
type: String,
required: true
},
role:{
type: String
},
date:{
type: Date,
default: Date.now
}
})
const User = mongoose.model('users', UserSchema)
我唯一关心的是如何根据用户关联的公司将用户重定向到特定页面。
现在我正在使用此代码作为我的登录名,在连续登录后它会转到“添加”页面。有什么方法可以让我将特定的登录用户重定向到特定的页面?
router.post('/login', (req, res, next)=>{
passport.authenticate('local', {
successRedirect: '/ideas/add',
failureRedirect: './login',
failureFlash: true
})(req, res, next)
})
【问题讨论】:
-
我认为如果你将他们重定向到相同的路线会更好,并使用动态模板让每个用户根据他们的公司看到特定的页面。
-
这个问题确实比问题所暗示的更根深蒂固,你在这里问的是如何实现multitenancy,这个问题以前在这里已经回答过几次,但它也是一个我认为过于宽泛。
标签: node.js express passport.js passport-local