Compare commits
No commits in common. "5aaca4234a926a880e7bcef52fdf06b5abde8e98" and "b1dc5e67c02a45b255224cabce2b2a5718a83955" have entirely different histories.
5aaca4234a
...
b1dc5e67c0
@ -113,15 +113,7 @@ func EngagementFavoriteRecipe(ctx *gin.Context) {
|
|||||||
func EngagementMakeRecipe(ctx *gin.Context) {
|
func EngagementMakeRecipe(ctx *gin.Context) {
|
||||||
deps := ctx.MustGet("deps").(*domain.InjectedDependencies)
|
deps := ctx.MustGet("deps").(*domain.InjectedDependencies)
|
||||||
|
|
||||||
// Ensure user is logged in with a valid account
|
if !domain.IsLoggedIn(ctx) {
|
||||||
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.Header("HX-Redirect", domain.WEB_LOGIN)
|
||||||
ctx.Status(http.StatusOK)
|
ctx.Status(http.StatusOK)
|
||||||
return
|
return
|
||||||
@ -129,8 +121,9 @@ func EngagementMakeRecipe(ctx *gin.Context) {
|
|||||||
|
|
||||||
id := ctx.Param("id")
|
id := ctx.Param("id")
|
||||||
recipeId, _ := strconv.Atoi(id)
|
recipeId, _ := strconv.Atoi(id)
|
||||||
|
userId := ctx.MustGet("userId").(int)
|
||||||
|
|
||||||
if _, err := deps.EngagementService.UserMakeRecipe(user.Id, recipeId); err != nil {
|
if _, err := deps.EngagementService.UserMakeRecipe(userId, recipeId); err != nil {
|
||||||
ctx.JSON(http.StatusInternalServerError, gin.H{
|
ctx.JSON(http.StatusInternalServerError, gin.H{
|
||||||
"status": http.StatusInternalServerError,
|
"status": http.StatusInternalServerError,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user