duanhe3393 2019-05-11 15:51
浏览 139
已采纳

在jwt-auth中可以使用一个令牌用于两个模型吗?

I use jwt-auth for authentication and i have two authenticatable models in my project "User" and "Company". I have to different middlewares. one for "User" and one for "Company". and each model had its own token (saved in cookies).

This two model is related (user belongs to a company)

now i want to get a user and if the user belongs to Company, login the user as company too. it simple to do this, but i need to do this with just one token. because i want to use one request and one middleware.

Is there any way or method that i can set user token to company. instead of get new token from company?

  • 写回答

1条回答 默认 最新

  • dongshan2680 2019-05-11 21:29
    关注

    Generally speaking, this is not proper way. User should be authenticated, and not the Company, but user belongs to company, so you can modify/access/change data, within that relationship.

    IMO, you should go that path.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀