Replaced Gravatar with self-hosted avatars
Avatars are now obtained from Blender ID. They are downloaded from Blender ID and stored in the users' home project storage. Avatars can be synced via Celery and triggered from a webhook. The avatar can be obtained from the current user object in Python, or via pillar.api.users.avatar.url(user_dict). Avatars can be shown in the web frontend by: - an explicit image (like before but with a non-Gravatar URL) - a Vue.js component `user-avatar` - a Vue.js component `current-user-avatar` The latter is the most efficient for the current user, as it uses user info that's already injected into the webpage (so requires no extra queries).
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
export const UserEvents = {
|
||||
USER_LOADED: 'user-loaded',
|
||||
}
|
||||
let currentUserEventBus = new Vue();
|
||||
|
||||
class User{
|
||||
constructor(kwargs) {
|
||||
this.user_id = kwargs['user_id'] || '';
|
||||
this.username = kwargs['username'] || '';
|
||||
this.full_name = kwargs['full_name'] || '';
|
||||
this.gravatar = kwargs['gravatar'] || '';
|
||||
this.avatar_url = kwargs['avatar_url'] || '';
|
||||
this.email = kwargs['email'] || '';
|
||||
this.capabilities = kwargs['capabilities'] || [];
|
||||
this.badges_html = kwargs['badges_html'] || '';
|
||||
@@ -12,7 +17,7 @@ class User{
|
||||
|
||||
/**
|
||||
* """Returns True iff the user has one or more of the given capabilities."""
|
||||
* @param {...String} args
|
||||
* @param {...String} args
|
||||
*/
|
||||
hasCap(...args) {
|
||||
for(let cap of args) {
|
||||
@@ -25,10 +30,16 @@ class User{
|
||||
let currentUser;
|
||||
function initCurrentUser(kwargs){
|
||||
currentUser = new User(kwargs);
|
||||
currentUserEventBus.$emit(UserEvents.USER_LOADED, currentUser);
|
||||
}
|
||||
|
||||
function getCurrentUser() {
|
||||
return currentUser;
|
||||
}
|
||||
|
||||
export { getCurrentUser, initCurrentUser }
|
||||
function updateCurrentUser(user) {
|
||||
currentUser = user;
|
||||
currentUserEventBus.$emit(UserEvents.USER_LOADED, currentUser);
|
||||
}
|
||||
|
||||
export { getCurrentUser, initCurrentUser, updateCurrentUser, currentUserEventBus }
|
||||
|
Reference in New Issue
Block a user