Skip to content
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

Sign-out button #5

Open
hvbish opened this issue Jul 17, 2021 · 1 comment
Open

Sign-out button #5

hvbish opened this issue Jul 17, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@hvbish
Copy link
Contributor

hvbish commented Jul 17, 2021

It would be good to add a button that lets you sign out of your Spotify account. Currently, if a user wants to sign out or use the Wayfinder with another account, they have to delete browser cookies manually or use incognito mode.

@hvbish hvbish added the enhancement New feature or request label Jul 17, 2021
@stevenstetzler
Copy link
Member

This could be implemented easily I think...

Currently, the Flask app will check if a user is logged in by calling the check_logged_in() function before returning the visualization: https://github.com/The-Wayfinder-Society/wayfinder-app/blob/master/main.py#L279-L281

The check_logged_in() function inspects the browser cookies and will guide the user to the /login or /refresh page based on the status of the access tokens found: https://github.com/The-Wayfinder-Society/wayfinder-app/blob/master/main.py#L90-L113

I think we can create a new function logout() that would clear these cookies and redirect the user to the homepage like so:

@app.route("/logout")
def logout():
    response = redirect(url_for("index"))
    response.set_cookie("SpotifyUserAccessToken", "", expires=0)
    response.set_cookie("SpotifyUserRefreshToken", "", expires=0)
    return response

in main.py and then add a new link to the Viz page (templates/viz.html) or main page (templates/index.html) like so:

<a href="/logout">Sign Out</a>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants