Devise - Make a request without resetting the countdown until a user is logged out due to inactivity

后端 未结 4 1142
孤城傲影
孤城傲影 2020-12-15 19:18

I\'m working on a RoR app with Devise. I want to let clients send a request to the server to see how much time is left until the user on the client is automatically logged o

4条回答
  •  忘掉有多难
    2020-12-15 19:48

    when i see this correctly (probably depending on the devise version) devise handles the logout through the Timeoutable module.

    this is hooked up to warden, which is part of the rack middleware stack.

    if you look at the code, than you can find this part:

    unless warden.request.env['devise.skip_trackable']
      warden.session(scope)['last_request_at'] = Time.now.utc
    end
    

    so from what i can see here, you should be able to set devise.skip_trackable to true before the warden middleware get's called.

    i think that this issue here explains how to actually use it: https://github.com/plataformatec/devise/issues/953

提交回复
热议问题