Add appstore accessToken to subscription setup links
This commit is contained in:
@@ -2207,6 +2207,30 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.getAppstoreUserToken = function (callback) {
|
||||
post('/api/v1/appstore/user_token', {}, null, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 201) return callback(new ClientError(status, data));
|
||||
|
||||
callback(null, data.accessToken);
|
||||
});
|
||||
};
|
||||
|
||||
// This will change the location
|
||||
Client.prototype.openSubscriptionSetup = function (subscription) {
|
||||
var that = this;
|
||||
|
||||
this.getAppstoreUserToken(function (error, result) {
|
||||
if (error) return console.error('Unable to get appstore user token.', error);
|
||||
|
||||
var token = result;
|
||||
var email = subscription.emailEncoded;
|
||||
var cloudronId = subscription.cloudronId;
|
||||
|
||||
window.location.href = that.getConfig().webServerOrigin + '/console.html#/userprofile?view=subscriptions&email=' + email + '&cloudronId=' + cloudronId + '&token=' + token;
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.getAppstoreAppByIdAndVersion = function (appId, version, callback) {
|
||||
var url = '/api/v1/appstore/apps/' + appId;
|
||||
if (version && version !== 'latest') url += '/versions/' + version;
|
||||
|
||||
Reference in New Issue
Block a user