Skip to content

[BUG]: /profile renders for admins role #134

Description

@ayush00git

/profile works for admins as well which was designed for non-admins role users only. A known bug that was caused due to using admin role for the auth context in handlers/auth.go

case "admin":
		var profile models.Admin
		result := h.DB.Where("email = ?", email).Take(&profile)
		if result.Error != nil {
			c.JSON(500, gin.H{"error": "failed to fetch user profile"})
			return
		}
		// hand-pick the fields so the password hash never leaves the server
		userProfile = gin.H{
			"id":          profile.ID,
			"email":       profile.Email,
			"position":    profile.Position,
			"is_verified": profile.IsVerified,
			"created_at":  profile.CreatedAt,
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions