1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-19 23:48:51 +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,12 +171,21 @@ def get_onlyoffice_dict(request, username, repo_id, file_path, file_id='',
"customization": { "customization": {
"forcesave": ONLYOFFICE_FORCE_SAVE, "forcesave": ONLYOFFICE_FORCE_SAVE,
}, },
"user": { }
}
if request.user.is_authenticated:
user_dict = {
"id": username, "id": username,
"name": email2nickname(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_dict['onlyoffice_jwt_token'] = jwt.encode(config, ONLYOFFICE_JWT_SECRET)

View File

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