我正在为etherpad制作一个插件,用于检查用户是否经过身份验证。如果没有,则显示只读。我走了这么远:
var eejs = require('ep_etherpad-lite/node/eejs');
var readOnlyManager = require("ep_etherpad-lite/node/db/ReadOnlyManager");
exports.route = function(hook_name, args, cb){
args.app.get('/p/:pad', function(req, res){
if(req.params.pad.indexOf('r.') === 0){
res.send(eejs.require("ep_etherpad-lite/templates/pad.html", {req: req}));
} else {
if(req.session.user){
res.send(eejs.require("ep_etherpad-lite/templates/pad.html", {req: req}));
} else {
readOnlyManager.getReadOnlyId(req.params.pad, function(err, readonlyID){
res.redirect('/p/'+readonlyID);
});
}
}
});
}
exports.logout = function(hook_name, args, cb){
args.app.get('/logout', function(req, res){
req.session.destroy(function(){
res.redirect('/');
});
});
}但是我不能使用post路由来进行我自己的用户登录。当我访问/login时,我怎样才能根据请求进行类似的一般身份验证呢?
发布于 2013-12-28 22:40:24
我在Etherpad上写了很多auth机制,但那是几年前的事了,我不知道它改变了多少。
您需要的API端点和关于auth如何在Etherpad文档 (特别是auth )中工作的文档将在认证文件中讨论。
很难从你的问题中判断出来,但看起来你想在/login上有某种登录页面吗?如果是的话,请回顾Etherpad是如何实现基本auth的,并通过在/login上创建一个新的express端点来调整它。
有各种各样的插件(包括我开发的插件),可以用来创建新的表达式端点,通知Etherpad插件
我从你的问题中得到了正确的结果吗?
https://stackoverflow.com/questions/20818727
复制相似问题