Make the UI capability based
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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); });
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user