diff --git a/seahub/profile/templates/profile/set_profile.html b/seahub/profile/templates/profile/set_profile.html index f7b258dbb3..e69717e571 100644 --- a/seahub/profile/templates/profile/set_profile.html +++ b/seahub/profile/templates/profile/set_profile.html @@ -79,6 +79,18 @@ {% endif %} +{% if ENABLE_WEBDAV_SECRET %} +
+

WebDav {% trans "Password" %}

+ +
+ {% trans "Update" %} + {% trans "Delete" %} + +
+{% endif %} + + {% if ENABLE_ADDRESSBOOK_OPT_IN %}

{% trans "Global Address Book" %}

@@ -233,6 +245,33 @@ $("#list-in-address-book input[type='checkbox']").on('change', function() { }); {% endif %} +{% if ENABLE_WEBDAV_SECRET %} +function aj_update_webdav_secret(passwd) { + $.ajax({ + url: "{% url 'api-v2.1-webdav-secret' %}", + type: 'PUT', + dataType: 'json', + cache: false, + beforeSend: prepareCSRFToken, + data: "secret=" + passwd, + success: function(data) { + feedback("{% trans "Success" %}", 'success'); + }, + error: ajaxErrorHandler + }); +} + +$("#update-webdav-passwd a.update").click(function() { + var passwd = $("#update-webdav-passwd input[type='text']").val(); + aj_update_webdav_secret(passwd); +}); + +$("#update-webdav-passwd a.delete").click(function() { + $("#update-webdav-passwd input[type='text']").val(''); + aj_update_webdav_secret(''); +}); +{% endif %} + (function() { var lang_context = $('#lang-context'), lang_selector = $('#lang-context-selector'); diff --git a/seahub/profile/views.py b/seahub/profile/views.py index c0088b57a4..320f6fdd7e 100644 --- a/seahub/profile/views.py +++ b/seahub/profile/views.py @@ -75,6 +75,12 @@ def edit_profile(request): owned_repos = get_owned_repo_list(request) owned_repos = filter(lambda r: not r.is_virtual, owned_repos) + if settings.ENABLE_WEBDAV_SECRET: + decoded = UserOptions.objects.get_webdav_decoded_secret(username) + webdav_passwd = decoded if decoded else '' + else: + webdav_passwd = '' + resp_dict = { 'form': form, 'server_crypto': server_crypto, @@ -86,6 +92,8 @@ def edit_profile(request): 'is_ldap_user': is_ldap_user(request.user), 'two_factor_auth_enabled': has_two_factor_auth(), 'ENABLE_CHANGE_PASSWORD': settings.ENABLE_CHANGE_PASSWORD, + 'ENABLE_WEBDAV_SECRET': settings.ENABLE_WEBDAV_SECRET, + 'webdav_passwd': webdav_passwd, } if has_two_factor_auth():