-
Notifications
You must be signed in to change notification settings - Fork 881
feat: add feature to show warning to user if they are already logged in #14219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
BRAVO68WEB
commented
Aug 8, 2024
•
edited
Loading
edited
- feat: added feature to show warning to user if they are already logged in
closes #11004 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, could you fix the issues and also make sure the tests pass?
@mafredri Can you crosscheck now? |
cli/root.go
Outdated
|
||
// IF r.token and r.clientUR, exists then print warning "You are already logged in to $" | ||
if r.token != "" && r.clientURL.String() != "" { | ||
_, _ = fmt.Fprintf(inv.Stdout, Caret+"%s!\n", pretty.Sprint(cliui.DefaultStyles.Warn, "You are already logged in to "+r.clientURL.String())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about what we want to achieve with this warning. As it stands I imagine it will be slightly annoying to see the warning but not be able to do an action based on it.
Also, the token could be expired so then we're kind of lying to the user as they're not really logged in.
Should we move this from middleware and prompt the user for what to do instead (+ verify token is valid)? WDYT @matifali?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree 💯. Checking token for validity should be a must and if expired should instruct the user to relogin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guys, give me a final rundown about what should I implement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for merge this should call the coder API to see what the current user is and print the username as well. If the request fails, any message should be suppressed.
This should also print to stderr rather than stdout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted
Hi @BRAVO68WEB , thank you for your contributions! Do you still plan to complete this PR? Looking forward to your updates. |
Sorry, was busy busy with work. Pushing my changes...... |
i am not about fetch current logged in user. |