小编Ian*_*Ian的帖子

Passport JS 管理员用户验证

我有一个前端带有 EJS 的 Node Express 应用程序。

我有一个带护照的中间件功能,它在所有创建、编辑、删除路由之前运行。

function isLoggedIn(req, res, next) {
    if (req.isAuthenticated()) {
        if (req.user._id != "12345") {
            res.redirect("/error");
        }
        return next();
    }
    res.redirect("/error");
}
Run Code Online (Sandbox Code Playgroud)

我能想到的最好的方法是通过 mongo db 中的用户 id 和 req.user._id 检查我的管理员用户是否是尝试访问该路由的用户

有没有更好的方法来处理管理员用户对路由和 html 组件的访问?

ejs node.js express passport.js

3
推荐指数
1
解决办法
3940
查看次数

如何更改默认的 Bootstrap 手风琴按钮?

想知道是否有人知道如何更改 Bootstrap 4、5 手风琴的默认折叠按钮?

我想用 fontawesome 自定义它们。谢谢!

示例手风琴:

<div class="accordion" id="accordionExample">
  <div class="accordion-item">
    <h2 class="accordion-header" id="headingOne">
      <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
        Accordion Item #1
      </button>
    </h2>
    <div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        <strong>This is the first item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. …
Run Code Online (Sandbox Code Playgroud)

bootstrap-4 bootstrap-5

0
推荐指数
1
解决办法
710
查看次数

标签 统计

bootstrap-4 ×1

bootstrap-5 ×1

ejs ×1

express ×1

node.js ×1

passport.js ×1