Matrix/entities/device/deviceController.go
2020-10-04 14:22:52 +02:00

30 lines
519 B
Go

package device
import "nutfactory.org/Matrix/utils"
func New(name string) (err error, device *Device) {
err, id := utils.CreateUUID()
if err != nil {
return
}
err, token := utils.CreateToken()
if err != nil {
return
}
device = &Device{
Id: id,
Name: name,
AccessToken: token,
Keys: make(map[string]*Key),
}
return
}
func (device *Device) RenewAccesToken() (err error) {
err, token := utils.CreateToken()
if err != nil {
return
}
device.AccessToken = token
return
}