1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 03:50:04 +02:00
OpenSTF/res/app/components/stf/user/user-service.js

27 lines
753 B
JavaScript

module.exports = function UserServiceFactory($http, AppState) {
var UserService = {}
var user = UserService.currentUser = AppState.user
UserService.getAdbKeys = function() {
return (user.adbKeys || (user.adbKeys = []))
}
UserService.addAdbKey = function(key) {
return $http.post('/api/v1/app/user/keys/adb', key)
.success(function(data) {
UserService.getAdbKeys().push(data.key)
})
}
UserService.removeAdbKey = function(key) {
return $http.delete('/api/v1/app/user/keys/adb/' + key.fingerprint)
.success(function() {
user.adbKeys = UserService.getAdbKeys().filter(function(someKey) {
return someKey.fingerprint !== key.fingerprint
})
})
}
return UserService
}