= Redirect to original page after login

When the user attempts to open a page that requires authentication, Rodauth
redirects them to the login page. It can be useful to redirect them back to
the page they originally requested after successful login.  Similarly, you
can do this for pages requiring multifactor authentication.

  plugin :rodauth do
    enable :login, :logout, :otp

    # Have successful login redirect back to originally requested page
    login_return_to_requested_location? true

    # Have successful multifactor authentication redirect back to
    # originally requested page
    two_factor_auth_return_to_requested_location? true
  end

You can manually set which page to redirect after login or multifactor
authentication, though it is questionable whether the user will desire
this behavior compared to the default.

  route do |r|
    r.rodauth

    # Return the last visited path after login
    if rodauth.logged_in?
      # Return to the last visited page after multifactor authentication
      unless rodauth.two_factor_authenticated?
        session[rodauth.two_factor_auth_redirect_session_key] = request.fullpath
      end
    else
      session[rodauth.login_redirect_session_key] = request.fullpath
    end

    # rest of routes
  end
