fix(session panic): check if nil before use
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ad6bcac326
commit
be1709794a
@ -15,15 +15,15 @@ func Admin() echo.HandlerFunc {
|
||||
|
||||
func Index() echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
sess, _ := session.Get(setting.SessionCookieName(), c)
|
||||
|
||||
username := sess.Values["username"]
|
||||
if username != nil {
|
||||
return c.Redirect(http.StatusFound, "/home")
|
||||
}
|
||||
|
||||
addHeaders(c)
|
||||
|
||||
if sess, _ := session.Get(setting.SessionCookieName(), c); sess != nil {
|
||||
username := sess.Values["username"]
|
||||
if username != nil {
|
||||
return c.Redirect(http.StatusFound, "/home")
|
||||
}
|
||||
}
|
||||
|
||||
csrf := c.Get("csrf").(string)
|
||||
|
||||
err := c.Render(
|
||||
|
@ -17,11 +17,11 @@ func Signin() echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
addHeaders(c)
|
||||
|
||||
sess, _ := session.Get(setting.SessionCookieName(), c)
|
||||
|
||||
username := sess.Values["username"]
|
||||
if username != nil {
|
||||
return c.Redirect(http.StatusFound, "/home")
|
||||
if sess, _ := session.Get(setting.SessionCookieName(), c); sess != nil {
|
||||
username := sess.Values["username"]
|
||||
if username != nil {
|
||||
return c.Redirect(http.StatusFound, "/home")
|
||||
}
|
||||
}
|
||||
|
||||
return c.Render(
|
||||
|
Loading…
Reference in New Issue
Block a user