-
Notifications
You must be signed in to change notification settings - Fork 1
Shitty God Mode: Debugging User Management Utilities
Jorge Silva edited this page Mar 25, 2016
·
6 revisions
There are a couple of useful functions that people can use from the inside runnable-angular in order to do some common actions related to debugging and user management
// Here You can type your custom JavaScript...
// Here You can type your custom JavaScript...
var inject = function (serviceName) {
var service = angular.element(document.body).injector().get(serviceName);
window[serviceName] = service;
return service;
};
var getGithubOrgId = function (name) {
inject('$http');
inject('configAPIHost');
return $http({
method: 'get',
url: configAPIHost + '/github/orgs/' + name
})
.then(function (res) {
console.log('Id', res.data.id);
return res.data;
});
};
var deleteAllInvitations = function () {
inject('fetchUser');
inject('promisify');
inject('fetchGithubOrgId');
inject('$state');
inject('$q');
return fetchUser()
.then(function (user) {
return $q.when(fetchGithubOrgId($state.params.userName))
.then(function (id) {
return promisify(user, 'fetchTeammateInvitations')({
orgGithubId: id
})
})
.then(function (invitations) {
return $q.all(invitations.map(function (invite) {
console.log(invite.id());
return promisify(user, 'destroyTeammateInvitation')(invite.id())
.then(() => console.log('Success'))
.catch(() => console.log('Failure'))
}));
});
});
};
var whiteListOrg = function (orgName) {
inject('configAPIHost');
inject('$http');
return $http({
url: configAPIHost + '/auth/whitelist',
method: "POST",
data: { 'name' : orgName }
})
.then(function (data) {
console.log(data);
});
};
var loginAsUser = function (accessToken) {
inject('$http')
inject('configAPIHost');
console.log('configAPIHost', configAPIHost, accessToken);
return $http.post(
configAPIHost + '/auth/github/token',
{accessToken: accessToken}
)
}
You can either copy/paste the following scripts above into the console every time you want to use them, or you can use this Chrome plugin to save them permanently and bind them to a specific URL.