Compare commits

..

No commits in common. "9acec1b6ffb87b40c3d179062e9df497153b971a" and "ab3edafc70d466f5bd45c4b837d5143f94714d98" have entirely different histories.

5 changed files with 2 additions and 136 deletions

View File

@ -741,21 +741,6 @@ namespace VELConnect
); );
} }
public static void Unpair()
{
if (instance.state?.device != null)
{
PostRequestCallback(
instance.velConnectUrl + "/unpair/",
JsonConvert.SerializeObject(new Dictionary<string, string>()
{
{ "device_id", instance.state.device.id },
{ "user_id", instance.state.user.id }
})
);
}
}
// TODO // TODO
public static void UploadFile(string fileName, byte[] fileData, Action<string> successCallback = null) public static void UploadFile(string fileName, byte[] fileData, Action<string> successCallback = null)
{ {

View File

@ -1,7 +1,7 @@
{ {
"name": "edu.uga.engr.vel.vel-connect", "name": "edu.uga.engr.vel.vel-connect",
"displayName": "VEL-Connect", "displayName": "VEL-Connect",
"version": "2.1.1", "version": "2.1.0",
"unity": "2019.1", "unity": "2019.1",
"description": "Web-based configuration for VR applications", "description": "Web-based configuration for VR applications",
"keywords": [], "keywords": [],

View File

@ -1,6 +1,6 @@
{ {
"name": "@velaboratory/velconnect-svelte", "name": "@velaboratory/velconnect-svelte",
"version": "1.0.6", "version": "1.0.5",
"description": "Use VEL-Connect with a Svelte dashboard", "description": "Use VEL-Connect with a Svelte dashboard",
"main": "src/index.js", "main": "src/index.js",
"files": [ "files": [

View File

@ -199,59 +199,6 @@ func main() {
apis.ActivityLogger(app), apis.ActivityLogger(app),
) )
// TODO
// e.Router.POST("/pair", func(c echo.Context) error {
// removes a device from users that own it, and removes its owners
// this has no auth protection - maybe there could be a "device secret", that lets devices change themselves securely
e.Router.POST("/unpair", func(c echo.Context) error {
// we need to:
// - remove the device from the list of devices on the user account
// - remove the owner from the device
// - remove the device datablock from the device
// - add a new device datablock to the device
//
// Inputs:
// - device_id
// - user_id
requestData := apis.RequestData(c)
deviceId := requestData.Data["device_id"].(string)
userId := requestData.Data["user_id"].(string)
deviceRecord, deviceErr := app.Dao().FindRecordById("Device", deviceId)
userRecord, userErr := app.Dao().FindRecordById("Users", userId)
if deviceErr != nil {
return apis.NewNotFoundError("The device does not exist.", deviceErr)
}
if userErr != nil {
return apis.NewNotFoundError("The user does not exist.", userErr)
}
// remove the device from the owner's list of devices
userDevicesList := userRecord.GetStringSlice("devices")
removeCurrentDevice := func(s string) bool { return s != deviceId }
filteredUserDevicesList := filter(userDevicesList, removeCurrentDevice)
userRecord.Set("devices", filteredUserDevicesList)
// modify the device
deviceRecord.Set("owner", nil)
// create new device data
collection, err := app.Dao().FindCollectionByNameOrId("DataBlock")
if err != nil {
log.Fatalln("Couldn't create datablock")
return err
}
deviceDataRecord := models.NewRecord(collection)
deviceDataRecord.RefreshId()
deviceRecord.Set("data", deviceDataRecord.Id)
deviceDataRecord.Set("category", "device")
deviceDataRecord.Set("data", "{}")
return c.JSON(http.StatusOK, deviceRecord)
},
apis.ActivityLogger(app),
)
return nil return nil
}) })
@ -284,12 +231,3 @@ func mergeDataBlock(requestData *models.RequestData, record *models.Record) {
record.Set("data", existingDataMap) record.Set("data", existingDataMap)
} }
} }
func filter(ss []string, test func(string) bool) (ret []string) {
for _, s := range ss {
if test(s) {
ret = append(ret, s)
}
}
return
}

View File

@ -1,57 +0,0 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
options := map[string]any{}
json.Unmarshal([]byte(`{
"allowEmailAuth": true,
"allowOAuth2Auth": true,
"allowUsernameAuth": true,
"exceptEmailDomains": null,
"manageRule": null,
"minPasswordLength": 6,
"onlyEmailDomains": null,
"requireEmail": false
}`), &options)
collection.SetOptions(options)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
options := map[string]any{}
json.Unmarshal([]byte(`{
"allowEmailAuth": true,
"allowOAuth2Auth": true,
"allowUsernameAuth": true,
"exceptEmailDomains": null,
"manageRule": null,
"minPasswordLength": 8,
"onlyEmailDomains": null,
"requireEmail": false
}`), &options)
collection.SetOptions(options)
return dao.SaveCollection(collection)
})
}