-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Conversation
auth/templates/actions/users.go.tmpl
Outdated
@@ -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() |
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.
Error check please. :)
auth/templates/actions/auth.go.tmpl
Outdated
@@ -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 { |
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.
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.
@markbates just implemented those changes, thanks for your review! |
love it. Thanks |
related to #9