Skip to content

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

Closed
wants to merge 5 commits into from

Conversation

BRAVO68WEB
Copy link
Contributor

@BRAVO68WEB BRAVO68WEB commented Aug 8, 2024

  • feat: added feature to show warning to user if they are already logged in

@cdr-bot cdr-bot bot added the community Pull Requests and issues created by the community. label Aug 8, 2024
@BRAVO68WEB BRAVO68WEB changed the title feat/reauth warn feat: added feature to show warning to user if they are already logged in Aug 8, 2024
@BRAVO68WEB BRAVO68WEB changed the title feat: added feature to show warning to user if they are already logged in feat: add feature to show warning to user if they are already logged in Aug 8, 2024
@BRAVO68WEB
Copy link
Contributor Author

closes #11004

@BRAVO68WEB
Copy link
Contributor Author

image

@matifali matifali requested review from mafredri and coadler August 8, 2024 20:34
Copy link
Member

@mafredri mafredri left a 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?

@BRAVO68WEB
Copy link
Contributor Author

@mafredri Can you crosscheck now?

@BRAVO68WEB BRAVO68WEB requested a review from mafredri August 9, 2024 14:19
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()))
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted

@github-actions github-actions bot added the stale This issue is like stale bread. label Aug 20, 2024
@matifali matifali requested a review from mafredri August 22, 2024 11:21
@matifali matifali removed the stale This issue is like stale bread. label Aug 22, 2024
@matifali
Copy link
Member

Hi @BRAVO68WEB , thank you for your contributions! Do you still plan to complete this PR? Looking forward to your updates.

@BRAVO68WEB
Copy link
Contributor Author

Sorry, was busy busy with work. Pushing my changes......

@BRAVO68WEB
Copy link
Contributor Author

i am not about fetch current logged in user.

@github-actions github-actions bot added the stale This issue is like stale bread. label Sep 5, 2024
@github-actions github-actions bot closed this Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Pull Requests and issues created by the community. stale This issue is like stale bread.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants