set parentType in idManager.go
This commit is contained in:
2 files changed
+6
-5
No files matched your search
@@ -18,7 +18,7 @@ var idCollection *mongo.Collection = database.OpenCollection(database.Client, "c
|
||||
|
||||
var table = [...]byte{'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'}
|
||||
|
||||
func ValidateID(id string) bool { // true: valid id, false: id already in use
|
||||
func ValidateID(id string, userType int) bool { // true: valid id, false: id already in use
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
var foundID models.Id
|
||||
err := idCollection.FindOne(ctx, bson.M{"cid": id}).Decode(&foundID)
|
||||
@@ -26,6 +26,7 @@ func ValidateID(id string) bool { // true: valid id, false: id already in use
|
||||
if err != nil { // If there is no id found create new ID object to be stored and return true (unless insert error then try again)
|
||||
var newID models.Id
|
||||
newID.CID = id
|
||||
newID.ParentType = userType
|
||||
newID.ID = primitive.NewObjectID()
|
||||
_, insertErr := idCollection.InsertOne(context.Background(), newID)
|
||||
if insertErr != nil {
|
||||
|
||||
Reference in new issue
Block a user