Skip to content

Commit

Permalink
Merge pull request #28 from mynaparrot/update
Browse files Browse the repository at this point in the history
Fix: invalid method
  • Loading branch information
jibon57 authored May 10, 2022
2 parents 5577a02 + 13e714e commit 4d5f9af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
29 changes: 3 additions & 26 deletions internal/controllers/auth_token.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package controllers

import (
"encoding/json"
"github.com/gofiber/fiber/v2"
"github.com/livekit/protocol/auth"
"github.com/mynaparrot/plugNmeet/internal/config"
Expand Down Expand Up @@ -101,24 +100,9 @@ func HandleVerifyToken(c *fiber.Ctx) error {
}

cm := c.Locals("claims")
// after usage, we can make it null
// as we don't need this value again.
// after usage, we can make it null as we don't need this value again.
c.Locals("claims", nil)

claims := new(auth.ClaimGrants)
err = json.Unmarshal([]byte(cm.(string)), claims)

if err != nil {
return c.JSON(fiber.Map{
"status": false,
"msg": err.Error(),
})
}

// if user id isn't string then will have problem
// so, we'll set it again here
claims.Identity = requestedUserId.(string)
claims.Video.Room = roomId.(string)
claims := cm.(*auth.ClaimGrants)

au := models.NewAuthTokenModel()
token, err := au.GenerateLivekitToken(claims)
Expand Down Expand Up @@ -193,14 +177,7 @@ func HandleVerifyHeaderToken(c *fiber.Ctx) error {
// we only need this during verify token
// because it will return livekit token, if success
if strings.Contains(c.Path(), "verifyToken") {
j, err := json.Marshal(claims)
if err != nil {
return c.JSON(fiber.Map{
"status": false,
"msg": err.Error(),
})
}
c.Locals("claims", string(j))
c.Locals("claims", claims)
}

c.Locals("isAdmin", claims.Video.RoomAdmin)
Expand Down
4 changes: 2 additions & 2 deletions internal/models/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func NewWebhookModel(e *livekit.WebhookEvent) {
w.participantLeft()

case "track_published":
w.participantJoined()
w.trackPublished()
case "track_unpublished":
w.participantLeft()
w.trackUnpublished()
}

}
Expand Down

0 comments on commit 4d5f9af

Please sign in to comment.