Skip to content

How might you add request info in session information? #4369

@reconbot

Description

@reconbot

Question 💬

I'd like to capture browser, last accessed and IP info when a database session is created or accessed. (Think gmail's "Last account activity" section)

In the future it would be nice to be able to invalidate sessions when I detect things change (say maybe the country changes?) or stop logins if you login from two countries at the same time. But what I need help with is;

  1. I can update a database session's last accessed manually in the session callback (I don't have adapter access but I can make a global one), but I can't return null and log someone out.
  2. I don't have access to any request information in createSession() in my adapter or session() in the nextauth callback. So I can't grab ip addresses or User-Agent headers.

Are there better approaches? Am I asking for new features?

How to reproduce ☕️

Nothing to reproduce, I'm either asking for api changes or ways to work around the issue.

Contributing 🙌🏽

Yes, I am willing to help answer this question in a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions