Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Etherpad:连接到auth的最佳方式_Node.js_Express_Etherpad - Fatal编程技术网

Node.js Etherpad:连接到auth的最佳方式

Node.js Etherpad:连接到auth的最佳方式,node.js,express,etherpad,Node.js,Express,Etherpad,我正在为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/:pa

我正在为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路由进行自己的用户登录。我怎么能像一般的请求身份验证一样,比如说当我访问/登录时?

我在Etherpad中写了很多身份验证机制,但那是几年前的事了,我不知道从那以后它发生了多少变化

中提供了所需的API端点以及有关auth如何工作的文档,特别是auth,将在中讨论

很难从你的问题中分辨出来,但看起来你想在/login上有某种登录页面?如果是这样,请查看Etherpad是如何实现基本身份验证的,并通过在/login处创建新的express端点来调整它

有各种插件(包括我开发的插件)可用于创建新的express端点

我从你的问题中得到了正确的答案吗?

部分是:)我已经尝试了很多东西,但似乎都没有成功。但是指向auth文档,我必须更仔细地阅读它们。