// ActivateUser allows to activate a user by its id
ActivateUser allows to activate a user by its id
// ActivateUser allows to activate a user by its id
func (db *Mngo) ActivateUser(activationKey string, id string) error {
	c := db.database.Collection(models.UsersCollection)
	result, err := c.UpdateOne(context.TODO(), bson.M{"$and": []bson.M{{"_id": id}, {"activation_key": activationKey}}}, bson.M{"$set": bson.M{"status": "activated"}}, options.Update().SetUpsert(false))
	if err != nil {
		log.Fatal(err)
		return helpers.NewError(http.StatusInternalServerError, "user_activation_failed", "Couldn't find the user to activate", err)
	}
	if result.MatchedCount != 0 {
		fmt.Println("matched and activated a user")
		return nil
	}
	if result.UpsertedCount != 0 {
		fmt.Printf("ActivateUser: inserted a new document with ID %v\n", result.UpsertedID)
		return nil
	}
	return nil
}
func ( db * Mngo ) ActivateUser ( activationKey string , id string ) error { c := db . database . Collection ( models . UsersCollection ) result , err := c . UpdateOne ( context . TODO ( ) , bson . M { " " : [ ] bson . M { { " " : id } , { " " : activationKey } } } , bson . M { " " : bson . M { " " : " " } } , options . Update ( ) . SetUpsert ( false ) ) if err != nil { log . Fatal ( err ) return helpers . NewError ( http . StatusInternalServerError , " " , " " , err ) } if result . MatchedCount != 0 { fmt . Println ( " " ) return nil } if result . UpsertedCount != 0 { fmt . Printf ( " \n " , result . UpsertedID ) return nil } return nil }
ActivateUser allows to activate a user by its id
ActivateUser allows to activate a user by its id