(FIX): This got missed...
This is part of the merge that fixed the issues with the nil derefs
This commit is contained in:
parent
eccc4885cc
commit
09aa311d52
@ -113,7 +113,15 @@ func EngagementFavoriteRecipe(ctx *gin.Context) {
|
||||
func EngagementMakeRecipe(ctx *gin.Context) {
|
||||
deps := ctx.MustGet("deps").(*domain.InjectedDependencies)
|
||||
|
||||
if !domain.IsLoggedIn(ctx) {
|
||||
// Ensure user is logged in with a valid account
|
||||
user := deps.UserService.GetAuthenicatedUser(ctx)
|
||||
if user == nil {
|
||||
// Log (stale) user out
|
||||
domain.SetCookie(ctx, "jwt_token", "", -1)
|
||||
domain.SetCookie(ctx, "search-filters", "", -1)
|
||||
}
|
||||
|
||||
if !domain.IsLoggedIn(ctx) || user == nil {
|
||||
ctx.Header("HX-Redirect", domain.WEB_LOGIN)
|
||||
ctx.Status(http.StatusOK)
|
||||
return
|
||||
@ -121,9 +129,8 @@ func EngagementMakeRecipe(ctx *gin.Context) {
|
||||
|
||||
id := ctx.Param("id")
|
||||
recipeId, _ := strconv.Atoi(id)
|
||||
userId := ctx.MustGet("userId").(int)
|
||||
|
||||
if _, err := deps.EngagementService.UserMakeRecipe(userId, recipeId); err != nil {
|
||||
if _, err := deps.EngagementService.UserMakeRecipe(user.Id, recipeId); err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{
|
||||
"status": http.StatusInternalServerError,
|
||||
"message": err.Error(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user