Force user change password when loading any webpage

后端 未结 2 1890
予麋鹿
予麋鹿 2021-01-27 23:33

I am using ASP.net core 2.0. I added a flag column called IsChangePassword to my AspNetUsers table and to my ApplicationUser class. The idea is to force the user to change their

2条回答
  •  无人共我
    2021-01-28 00:15

    I would use a middleware, in which I would check the HttpContext for the current principal and check the IsChangePassword property value of the underlying user.

    Then, according to the IsChangePassword property value, I would redirect the current request to the change password form.

    The pro of this solution is that you don't need to edit any actions and controllers.

    The con is that you add a if statement to every requests but additional configuration is possible.

提交回复
热议问题