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

Create middleware #3

Open
dimensi0n opened this issue Nov 6, 2020 · 4 comments
Open

Create middleware #3

dimensi0n opened this issue Nov 6, 2020 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@dimensi0n
Copy link
Owner

Why ?

Because people does not want to lose time on making a middleware

To-Do

Create a middleware to redirect the user to as specified page in the config if it is not loggedin.

@dimensi0n dimensi0n added enhancement New feature or request good first issue Good for newcomers labels Nov 6, 2020
@dimensi0n dimensi0n pinned this issue Nov 6, 2020
@franszhafran
Copy link

Hi, I'm new to Go and I think I can do this fix,

What I will do"

  1. Create new variable loggedIn and it's setter in Config
  2. Add a logic for each function that needs loggedIn

Is this the right approach? If you think so I will start on code for this issue

@dimensi0n
Copy link
Owner Author

Hello I am glad to see that you are interested in this issue. If you want to know if someone is already connected just call the GetCurrentUser function.
You can take a look at this if you need help : https://www.alexedwards.net/blog/making-and-using-middleware
you just need to call GetCurrentUser(r) (r is the request), if it returns an error redirect to '/login' by using http.Redirect() method.
and that's it.

@franszhafran
Copy link

Okay understood, I will work on this issue, I will notify you later than when it has been solved okay?

@dimensi0n
Copy link
Owner Author

Okay 👍

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

No branches or pull requests

2 participants