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,14 +15,14 @@ func Admin() echo.HandlerFunc {
|
||||
|
||||
func Index() echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
sess, _ := session.Get(setting.SessionCookieName(), c)
|
||||
addHeaders(c)
|
||||
|
||||
if sess, _ := session.Get(setting.SessionCookieName(), c); sess != nil {
|
||||
username := sess.Values["username"]
|
||||
if username != nil {
|
||||
return c.Redirect(http.StatusFound, "/home")
|
||||
}
|
||||
|
||||
addHeaders(c)
|
||||
}
|
||||
|
||||
csrf := c.Get("csrf").(string)
|
||||
|
||||
|
@ -17,12 +17,12 @@ func Signin() echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
addHeaders(c)
|
||||
|
||||
sess, _ := session.Get(setting.SessionCookieName(), c)
|
||||
|
||||
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(
|
||||
http.StatusOK,
|
||||
|
Loading…
Reference in New Issue
Block a user