fix: fallback to user email when username is unset#237
Conversation
|
I'm facing the same problem. This occurs if fetching the username via OIDC fails, leading to an inability to control users. I previously submitted a patch to Headscale that would fall back to the default email address upon username fetching failure. However, it was closed, possibly due to concerns about complex ACL controls, and wasn't merged. It would be fantastic if Headplane could offer a solution for this! |
tale
left a comment
There was a problem hiding this comment.
Overall fine, just change all the logical ors (||) to use nullish coalescing operators instead (??).
87b6cca to
71e0134
Compare
|
@tale Oh thanks, I didn't know that operator existed. Done! |
|
@tale I was just testing v0.6.1-next in #256 and I noticed this isn't working correctly. I believe it's because nullish coalescing operators only use the fallback value when the first value is null or undefined, but when username is unset, it's an empty string. A logical or worked here since an empty string is falsy. Should I open another PR to change it to a logical or? |
More recent versions of Headscale have changed username to be an optional field, causing the Machines page to show an empty field where the username would normally be displayed. This PR makes it fallback to displaying the email when this is the case.
I'm not very familiar with React, so let me know if there's a better way to do this. I'd love to be able to see which user manages a machine at a glance again!
Before
After