1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-02 07:47:32 +00:00

Merge pull request #5034 from haiwen/onlyoffice-co-editing-change-name

can change name when anonymous user edit file
This commit is contained in:
Daniel Pan 2021-11-17 13:51:59 +08:00 committed by GitHub
commit fa4bdcec3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -171,13 +171,22 @@ def get_onlyoffice_dict(request, username, repo_id, file_path, file_id='',
"customization": {
"forcesave": ONLYOFFICE_FORCE_SAVE,
},
"user": {
"id": username,
"name": email2nickname(username)
}
}
}
if request.user.is_authenticated:
user_dict = {
"id": username,
"name": email2nickname(username)
}
config['editorConfig']['user'] = user_dict
else:
anonymous_dict = {
"request": True,
"label": "Guest"
}
config['editorConfig']['customization']['anonymous'] = anonymous_dict
return_dict['onlyoffice_jwt_token'] = jwt.encode(config, ONLYOFFICE_JWT_SECRET)
return return_dict

View File

@ -44,11 +44,19 @@ html, body { padding:0; margin:0; height:100%; }
"mode": {% if can_edit %}"edit"{% else %}"view"{% endif %},
"customization": {
"forcesave": {% if onlyoffice_force_save %}true{% else %}false{% endif %},
{% if not request.user.is_authenticated %}
"anonymous": {
"request": true,
"label": "Guest"
},
{% endif %}
},
{% if request.user.is_authenticated %}
"user": {
"id": "{{ username|escapejs }}",
"name": "{{ username|email2nickname|escapejs }}"
}
{% endif %}
}
};
var docEditor = new DocsAPI.DocEditor("placeholder", config);