Make the UI capability based

This commit is contained in:
Girish Ramakrishnan
2018-06-17 18:21:12 -07:00
parent cec1cc7086
commit 4db703aeb1
9 changed files with 32 additions and 30 deletions

View File

@@ -111,7 +111,7 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
id: null,
username: null,
email: null,
admin: false,
caps: {},
twoFactorAuthenticationEnabled: false
};
this._config = {
@@ -224,11 +224,17 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
this._userInfo.email = userInfo.email;
this._userInfo.fallbackEmail = userInfo.fallbackEmail;
this._userInfo.displayName = userInfo.displayName;
this._userInfo.admin = !!userInfo.admin;
this._userInfo.twoFactorAuthenticationEnabled = userInfo.twoFactorAuthenticationEnabled;
this._userInfo.scope = userInfo.scope;
this._userInfo.tokenScope = userInfo.tokenScope;
this._userInfo.gravatar = 'https://www.gravatar.com/avatar/' + md5.createHash(userInfo.email) + '.jpg?s=24&d=mm';
this._userInfo.gravatarHuge = 'https://www.gravatar.com/avatar/' + md5.createHash(userInfo.email) + '.jpg?s=128&d=mm';
// clear and then set properties to keep angular happy
var caps = this._userInfo.caps;
for (var p in caps) delete caps[p];
userInfo.tokenScope.split(',').forEach(function (scope) {
caps[scope] = true;
});
};
Client.prototype.setConfig = function (config) {

View File

@@ -142,7 +142,7 @@ app.filter('appIsInstalledAndHealthy', function () {
app.filter('activeOAuthClients', function () {
return function (clients, user) {
return clients.filter(function (c) { return user.admin || (c.activeTokens && c.activeTokens.length > 0); });
return clients.filter(function (c) { return user.caps.clients || (c.activeTokens && c.activeTokens.length > 0); });
};
});

View File

@@ -179,7 +179,7 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
$scope.initialized = true;
if ($scope.user.admin) {
if ($scope.user.caps.cloudron) {
runConfigurationChecks();
$scope.fetchAppstoreProfileAndSubscription(function (error) {