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

Implements RedirectURL #10

Merged
merged 2 commits into from
Jun 20, 2018
Merged

Implements RedirectURL #10

merged 2 commits into from
Jun 20, 2018

Conversation

paganotoni
Copy link
Member

@paganotoni paganotoni commented Jun 19, 2018

related to #9

@@ -59,6 +59,9 @@ func SetCurrentUser(next buffalo.Handler) buffalo.Handler {
func Authorize(next buffalo.Handler) buffalo.Handler {
return func(c buffalo.Context) error {
if uid := c.Session().Get("current_user_id"); uid == nil {
c.Session().Set("redirectURL", c.Request().URL.String())
c.Session().Save()
Copy link
Member

Choose a reason for hiding this comment

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

Error check please. :)

@@ -55,7 +55,12 @@ func AuthCreate(c buffalo.Context) error {
c.Session().Set("current_user_id", u.ID)
c.Flash().Add("success", "Welcome Back to Buffalo!")

return c.Redirect(302, "/")
redirectURL := "/"
if c.Session().Get("redirectURL") != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of checking nil do a type assert instead. You can make this cleaner and safer. Currently the next line will panic if the value is anything other than a string.

@paganotoni
Copy link
Member Author

@markbates just implemented those changes, thanks for your review!

@markbates markbates merged commit 4d084dd into master Jun 20, 2018
@markbates
Copy link
Member

love it. Thanks

@markbates markbates deleted the feature/redirect-url branch June 20, 2018 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants