Deterministically expose username of logged-in user #9990

Closed
opened 2025-12-29 21:25:20 +01:00 by adam · 3 comments
Owner

Originally created by @jeffgdotorg on GitHub (Jul 17, 2024).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v4.0.7

Feature type

Change to existing functionality

Proposed functionality

Add an invisible DOM element, and/or inject a JS variable, that can be relied upon as a stable way to learn the username of the currently logged-in user. The item's absence, or its presence with a nullish value, indicates that no user is currently logged in. Implementation should be as independent as possible of the frontend technology stack, so that it remains useful across successive releases.

Use case

The immediate driver for this FR is an embedded help center present in some NetBox product editions. It's broadly useful enough, though, that it should be present in all instances.

Database changes

None

External dependencies

None

Originally created by @jeffgdotorg on GitHub (Jul 17, 2024). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v4.0.7 ### Feature type Change to existing functionality ### Proposed functionality Add an invisible DOM element, and/or inject a JS variable, that can be relied upon as a stable way to learn the username of the currently logged-in user. The item's absence, or its presence with a nullish value, indicates that no user is currently logged in. Implementation should be as independent as possible of the frontend technology stack, so that it remains useful across successive releases. ### Use case The immediate driver for this FR is an embedded help center present in some NetBox product editions. It's broadly useful enough, though, that it should be present in all instances. ### Database changes None ### External dependencies None
adam added the status: acceptedtype: featurecomplexity: low labels 2025-12-29 21:25:20 +01:00
adam closed this issue 2025-12-29 21:25:20 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 17, 2024):

We could do this with data attributes on e.g. the root element. (We already use this approach for conveying the view's URL name and base path.)

<html data-netbox-user-name="jstretch" data-netbox-user-id="123">
@jeremystretch commented on GitHub (Jul 17, 2024): We could do this with data attributes on e.g. the root element. (We already use this approach for conveying the view's URL name and base path.) ``` <html data-netbox-user-name="jstretch" data-netbox-user-id="123"> ```
Author
Owner

@RangerRick commented on GitHub (Jul 17, 2024):

We could do this with data attributes on e.g. the root element. (We already use this approach for conveying the view's URL name and base path.)

Ooh yeah, that would be perfect.

@RangerRick commented on GitHub (Jul 17, 2024): > We could do this with data attributes on e.g. the root element. (We already use this approach for conveying the view's URL name and base path.) Ooh yeah, that would be perfect.
Author
Owner

@jeremystretch commented on GitHub (Jul 17, 2024):

We discussed broadening the scope of this FR to also entail things like the running NetBox version and edition. I'm going to explore whether the approach above suffices or there's a more preferable convention for doing so.

@jeremystretch commented on GitHub (Jul 17, 2024): We discussed broadening the scope of this FR to also entail things like the running NetBox version and edition. I'm going to explore whether the approach above suffices or there's a more preferable convention for doing so.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9990