| 
														
															@@ -381,24 +381,13 @@ func (r *Registry) FindDeviceById(args uint64, reply *models.Device) error { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	if err != nil { 
														 | 
														
														 | 
														
															 	if err != nil { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		return err 
														 | 
														
														 | 
														
															 		return err 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	} 
														 | 
														
														 | 
														
															 	} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	cache := getCache() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	key := fmt.Sprintf("Device:%v", args) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	if v, ok := cache.Get(key);ok { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		device := v.(*models.Device) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		setDevice(reply, device) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	} else { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		d := &models.Device{} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		d.ID = uint(args) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		err = db.Where(d).First(reply).Error 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		if err != nil { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-			return err 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		var storage models.Device 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		storage = *reply 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		cache.Set(key, &storage) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	d := &models.Device{} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	d.ID = uint(args) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	err = db.Where(d).First(reply).Error 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	if err != nil { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		return err 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	} 
														 | 
														
														 | 
														
															 	} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	return nil 
														 | 
														
														 | 
														
															 	return nil 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -410,7 +399,7 @@ func (r *Registry) FindDeviceByRecordId(args *rpcs.ArgsDeviceAuth, reply *models 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	} 
														 | 
														
														 | 
														
															 	} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	cache := getCache() 
														 | 
														
														 | 
														
															 	cache := getCache() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	key := fmt.Sprintf("Device:%v", args.DeviceID) 
														 | 
														
														 | 
														
															 	key := fmt.Sprintf("Device:%v", args.DeviceID) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	if v, ok := cache.Get(key);ok { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+	if v, ok := cache.Get(key); ok { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		device := v.(*models.Device) 
														 | 
														
														 | 
														
															 		device := v.(*models.Device) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		setDevice(reply, device) 
														 | 
														
														 | 
														
															 		setDevice(reply, device) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	} else { 
														 | 
														
														 | 
														
															 	} else { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -425,12 +414,9 @@ func (r *Registry) FindDeviceByRecordId(args *rpcs.ArgsDeviceAuth, reply *models 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		cache.Set(key, &storage) 
														 | 
														
														 | 
														
															 		cache.Set(key, &storage) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	} 
														 | 
														
														 | 
														
															 	} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	return nil 
														 | 
														
														 | 
														
															 	return nil 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 // ValidateDevice will validate a device key and return the model if success. 
														 | 
														
														 | 
														
															 // ValidateDevice will validate a device key and return the model if success. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 func (r *Registry) ValidateDevice(key string, device *models.Device) error { 
														 | 
														
														 | 
														
															 func (r *Registry) ValidateDevice(key string, device *models.Device) error { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	id, err := r.keygen.DecodeIDFromRandomKey(key) 
														 | 
														
														 | 
														
															 	id, err := r.keygen.DecodeIDFromRandomKey(key) 
														 |