30 lines
534 B
Go
30 lines
534 B
Go
package device
|
|
|
|
import "git.nutfactory.org/hoernschen/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
|
|
}
|