Avoid a nil exception on error redirect
This commit is contained in:
parent
47f898561c
commit
f1e12f344e
|
@ -233,11 +233,23 @@ func NewPost() http.HandlerFunc {
|
|||
// A message OR a photo is required.
|
||||
if forum.PermitPhotos && message == "" && commentPhoto == nil {
|
||||
session.FlashError(w, r, "A message OR photo is required for this post.")
|
||||
templates.Redirect(w, fmt.Sprintf("/forum/thread/%d", thread.ID))
|
||||
if thread != nil {
|
||||
templates.Redirect(w, fmt.Sprintf("/forum/thread/%d", thread.ID))
|
||||
} else if forum != nil {
|
||||
templates.Redirect(w, fmt.Sprintf("/f/%s", forum.Fragment))
|
||||
} else {
|
||||
templates.Redirect(w, "/forum")
|
||||
}
|
||||
return
|
||||
} else if !forum.PermitPhotos && message == "" {
|
||||
session.FlashError(w, r, "A message is required for this post.")
|
||||
templates.Redirect(w, fmt.Sprintf("/forum/thread/%d", thread.ID))
|
||||
if thread != nil {
|
||||
templates.Redirect(w, fmt.Sprintf("/forum/thread/%d", thread.ID))
|
||||
} else if forum != nil {
|
||||
templates.Redirect(w, fmt.Sprintf("/f/%s", forum.Fragment))
|
||||
} else {
|
||||
templates.Redirect(w, "/forum")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user