Skip to content

Commit

Permalink
return mongo id as plaintext
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonay committed Mar 21, 2015
1 parent 43ac5a2 commit fc4d500
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions handlers/users_get_all.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package handlers

import (
"github.com/dmonay/okra/authentication"
"github.com/dmonay/okra/common"
"github.com/gin-gonic/gin"
"gopkg.in/mgo.v2/bson"
"os"
)

func (dw *DoWorkResource) GetAllUsers(c *gin.Context) {
Expand All @@ -17,20 +15,11 @@ func (dw *DoWorkResource) GetAllUsers(c *gin.Context) {
CheckErr(err, "Failed to get all users", c)
return
}
result := make(map[string][]byte)
result := make(map[string]bson.ObjectId)
count := 0
for _, value := range results {
count++
rawKey := os.Getenv("SECRET")
key := []byte(rawKey) // 32 bytes
plaintext := []byte(value.Id)

ciphertext, err2 := authentication.Encrypt(key, plaintext)
if err2 != nil {
CheckErr(err2, "Failed to encrypt key", c)
return
}
result[value.Username] = ciphertext
result[value.Username] = value.Id
if count == 7 {
break
}
Expand Down

0 comments on commit fc4d500

Please sign in to comment.