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.

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

报告相同问题?