Add support to upload custom profile avatar
This commit is contained in:
+28
-4
@@ -206,7 +206,8 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
username: null,
|
||||
email: null,
|
||||
twoFactorAuthenticationEnabled: false,
|
||||
source: null
|
||||
source: null,
|
||||
avatarUrl: null
|
||||
};
|
||||
this._config = {
|
||||
apiServerOrigin: null,
|
||||
@@ -332,8 +333,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
this._userInfo.twoFactorAuthenticationEnabled = userInfo.twoFactorAuthenticationEnabled;
|
||||
this._userInfo.admin = userInfo.admin;
|
||||
this._userInfo.source = userInfo.source;
|
||||
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';
|
||||
this._userInfo.avatarUrl = userInfo.avatarUrl;
|
||||
};
|
||||
|
||||
Client.prototype.setConfig = function (config) {
|
||||
@@ -1230,7 +1230,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
if (status !== 201) return callback(new ClientError(status, data));
|
||||
|
||||
that.setToken(data.token);
|
||||
that.setUserInfo({ username: username, email: email, admin: true, twoFactorAuthenticationEnabled: false, source: '' });
|
||||
that.setUserInfo({ username: username, email: email, admin: true, twoFactorAuthenticationEnabled: false, source: '', avatarUrl: null });
|
||||
|
||||
callback(null, data.activated);
|
||||
});
|
||||
@@ -1470,6 +1470,30 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.clearAvatar = function (callback) {
|
||||
del('/api/v1/profile/avatar', {}, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 202) return callback(new ClientError(status, data));
|
||||
callback(null);
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.changeAvatar = function (avatarFile, callback) {
|
||||
var fd = new FormData();
|
||||
fd.append('avatar', avatarFile);
|
||||
|
||||
var config = {
|
||||
headers: { 'Content-Type': undefined },
|
||||
transformRequest: angular.identity
|
||||
};
|
||||
|
||||
post('/api/v1/profile/avatar', fd, config, function (error, data, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 202) return callback(new ClientError(status, data));
|
||||
callback(null);
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.changePassword = function (currentPassword, newPassword, callback) {
|
||||
var data = {
|
||||
password: currentPassword,
|
||||
|
||||
Reference in New Issue
Block a user