Merge pull request '(FIX): This got missed...' (#38) from dev into master
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 40s
All checks were successful
Deploy application with Docker / build_and_deploy (push) Successful in 40s
Reviewed-on: #38
This commit is contained in:
commit
5aaca4234a
@ -113,7 +113,15 @@ 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)
|
||||||
|
|
||||||
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.Header("HX-Redirect", domain.WEB_LOGIN)
|
||||||
ctx.Status(http.StatusOK)
|
ctx.Status(http.StatusOK)
|
||||||
return
|
return
|
||||||
@ -121,9 +129,8 @@ 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(userId, recipeId); err != nil {
|
if _, err := deps.EngagementService.UserMakeRecipe(user.Id, 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