@@ -1025,8 +1025,10 @@ func (n *NativeEngine) CreateOrUpdate(twin uint32, deployment gridtypes.Deployme
1025
1025
1026
1026
// make sure the account used is verified
1027
1027
check := func () error {
1028
- if ! isTwinVerified (twin ) {
1029
- return fmt .Errorf ("user is not verified" )
1028
+ if ok , err := isTwinVerified (twin ); err != nil {
1029
+ return err
1030
+ } else if ! ok {
1031
+ return fmt .Errorf ("user with twin id %d is not verified" , twin )
1030
1032
}
1031
1033
return nil
1032
1034
}
@@ -1190,7 +1192,7 @@ func (e *NativeEngine) GetWorkloadStatus(id string) (gridtypes.ResultState, bool
1190
1192
}
1191
1193
1192
1194
// isTwinVerified make sure the account used is verified
1193
- func isTwinVerified (twinID uint32 ) (verified bool ) {
1195
+ func isTwinVerified (twinID uint32 ) (verified bool , err error ) {
1194
1196
const verifiedStatus = "VERIFIED"
1195
1197
env := environment .MustGet ()
1196
1198
@@ -1219,8 +1221,7 @@ func isTwinVerified(twinID uint32) (verified bool) {
1219
1221
defer response .Body .Close ()
1220
1222
1221
1223
if response .StatusCode != http .StatusOK {
1222
- log .Error ().Msg ("failed to get user status" )
1223
- return
1224
+ return verified , errors .New ("failed to get twin verification status" )
1224
1225
}
1225
1226
1226
1227
var result struct { Result struct { Status string } }
@@ -1230,5 +1231,5 @@ func isTwinVerified(twinID uint32) (verified bool) {
1230
1231
return
1231
1232
}
1232
1233
1233
- return result .Result .Status == verifiedStatus
1234
+ return result .Result .Status == verifiedStatus , nil
1234
1235
}
0 commit comments