代码之家  ›  专栏  ›  技术社区  ›  nusantara

如何在下一步从Auth0中删除用户。js?

  •  0
  • nusantara  · 技术社区  · 5 年前

    我可以在Next上登录和注销用户。js在阅读了这些资源之后:

    但是,我无法确定是否可以使用auth0/nextjs-auth0库删除用户。

    我还研究了模块的处理程序 here .

    我认为使用@auth0/nextjs-auth0库无法删除用户,对吗?

    如果是,删除用户的最佳方式是什么?我希望允许用户单击浏览器中的按钮从Auth0中删除自己。

    此时,我正在考虑使用 node-auth0 库执行此操作 solution :

     management.users.delete({ id: USER_ID }, function (err) {
        if (err) {
          // Handle error.
        }
     
        // User deleted.
      });
    

    但它需要一个节点后端,这是我想要避免的。即便如此,这是最好的解决方案还是有更好的解决方案?Auth0生态系统非常庞大。

    编辑2020年10月27日 :将在下一步的“无服务器”函数中尝试使用node-auth0库。js允许用户在周末删除他们的帐户。秘密隐藏在Next的 runtime configuration . 如果这不是最好的方法,请告诉我。谢谢

    0 回复  |  直到 5 年前
        1
  •  0
  •   Yilmaz    5 年前

    我相信你的意思是通过“删除用户”来注销用户。因为如果要从数据库中删除用户,必须有处理db连接的节点服务器。如果要注销用户,请在“pages/api/v1”中创建注销。js。在下一页中。js、无服务器函数或api函数都是在“页面/api”中编写的。

    import auth0 from "/utils/auth0"; 
    // auth0 file is where you set the configuration for the auth0.
    
    export default async function logout(req,res) {
      try {
        await auth0.handleLogout(req, res);
      } catch (error) {
        console.error(error);
        res.status(error.status || 400).end(error.message);
      }
    }  
    
    推荐文章