diff --git a/media/css/seahub.css b/media/css/seahub.css index ee8f781396..077976f1da 100644 --- a/media/css/seahub.css +++ b/media/css/seahub.css @@ -2065,3 +2065,11 @@ a.sf-popover-item { background: #6e7687; height: 12px; } + +#email-audit-form .email-input { + width: 172px; +} + +#email-audit-form .get-code-btn { + width: 102px; +} diff --git a/seahub/api2/utils.py b/seahub/api2/utils.py index f5c17ee249..6c5f35218a 100644 --- a/seahub/api2/utils.py +++ b/seahub/api2/utils.py @@ -32,6 +32,7 @@ from seahub.avatar.settings import AVATAR_DEFAULT_SIZE from seahub.avatar.templatetags.avatar_tags import api_avatar_url from seahub.utils import get_user_repos from seahub.utils.mail import send_html_email_with_dj_template +from django.utils.translation import gettext as _ from seahub.settings import SECRET_KEY logger = logging.getLogger(__name__) @@ -285,7 +286,7 @@ def is_web_request(request): return True else: return False - + def is_wiki_repo(repo): return repo.repo_type == REPO_TYPE_WIKI @@ -306,9 +307,9 @@ def get_search_repos(username, org_id): repos.append((repo.id, repo.origin_repo_id, repo.origin_path, repo.name)) return repos - + def send_share_link_emails(emails, fs, shared_from): - subject = "Share links" + subject = _("A share link for you") for email in emails: c = {'url': "%s?email=%s" % (fs.get_full_url(), email), 'shared_from': shared_from} send_success = send_html_email_with_dj_template( @@ -321,7 +322,7 @@ def send_share_link_emails(emails, fs, shared_from): continue def is_valid_internal_jwt(auth): - + if not auth or auth[0].lower()!= 'token' or len(auth) != 2: return False @@ -337,5 +338,5 @@ def is_valid_internal_jwt(auth): is_internal = payload.get('is_internal') if is_internal: return True - + return False diff --git a/seahub/share/decorators.py b/seahub/share/decorators.py index fb77ebbb06..854251e1c9 100644 --- a/seahub/share/decorators.py +++ b/seahub/share/decorators.py @@ -12,27 +12,33 @@ from seahub.share.models import FileShare, UploadLinkShare from seahub.share.utils import SCOPE_SPECIFIC_EMAILS, SCOPE_ALL_USERS, SCOPE_SPECIFIC_USERS from seahub.utils import render_error from seahub.utils import normalize_cache_key, is_pro_version, redirect_to_login +from seahub.utils.auth import get_login_bg_image_path from seahub.constants import REPO_SHARE_LINK_COUNT_LIMIT def _share_link_auth_email_entry(request, fileshare, func, *args, **kwargs): if request.user.username == fileshare.username: return func(request, fileshare, *args, **kwargs) - + session_key = "link_authed_email_%s" % fileshare.token if request.session.get(session_key) is not None: return func(request, fileshare, *args, **kwargs) - + + login_bg_image_path = get_login_bg_image_path() if request.method == 'GET': email = request.GET.get('email', '') - return render(request, 'share/share_link_email_audit.html', {'email': email, 'token': fileshare.token}) - + return render(request, 'share/share_link_email_audit.html', { + 'email': email, + 'token': fileshare.token, + 'login_bg_image_path': login_bg_image_path, + }) + elif request.method == 'POST': code_post = request.POST.get('code', '') email_post = request.POST.get('email', '') cache_key = normalize_cache_key(email_post, 'share_link_email_auth_', token=fileshare.token) code = cache.get(cache_key) - + authed_details = json.loads(fileshare.authed_details) if code == code_post and email_post in authed_details.get('authed_emails'): request.session[session_key] = email_post @@ -40,12 +46,13 @@ def _share_link_auth_email_entry(request, fileshare, func, *args, **kwargs): return func(request, fileshare, *args, **kwargs) else: return render(request, 'share/share_link_email_audit.html', { - 'err_msg': 'Invalid token, please try again.', + 'login_bg_image_path': login_bg_image_path, + 'err_msg': _('Invalid verification code, please try again.'), 'email': email_post, 'code': code, 'token': fileshare.token, 'code_verify': False - + }) else: assert False, 'TODO' @@ -56,7 +63,7 @@ def share_link_audit(func): def _decorated(request, token, *args, **kwargs): assert token is not None # Checked by URLconf - + is_for_upload = False try: fileshare = FileShare.objects.get(token=token) @@ -69,22 +76,22 @@ def share_link_audit(func): is_for_upload = True except UploadLinkShare.DoesNotExist: fileshare = None - + if not fileshare: return render_error(request, _('Link does not exist.')) - + if fileshare.is_expired(): return render_error(request, _('Link is expired.')) - + if is_for_upload: return func(request, fileshare, *args, **kwargs) - + if fileshare.user_scope in [SCOPE_ALL_USERS, SCOPE_SPECIFIC_USERS]: return func(request, fileshare, *args, **kwargs) if fileshare.user_scope == SCOPE_SPECIFIC_EMAILS: return _share_link_auth_email_entry(request, fileshare, func, *args, **kwargs) - + return _decorated def share_link_login_required(func): diff --git a/seahub/share/templates/share/audit_code_email.html b/seahub/share/templates/share/audit_code_email.html index beb6d691bd..e6f682f78c 100644 --- a/seahub/share/templates/share/audit_code_email.html +++ b/seahub/share/templates/share/audit_code_email.html @@ -2,15 +2,16 @@ {% load i18n %} {% block email_con %} - {% autoescape off %}
{% trans "Hi," %}
-{% blocktrans %}Your code is {{code}}, this code will be valid for one hour.{% endblocktrans%} +{% blocktrans %}The verification code is {{code}}, and it will be valid in one hour.{% endblocktrans%}
{% endautoescape %} - +{% endblock %} + +{% block thanks %} {% endblock %} diff --git a/seahub/share/templates/share/share_link_audit.html b/seahub/share/templates/share/share_link_audit.html deleted file mode 100644 index edf6d4e0ed..0000000000 --- a/seahub/share/templates/share/share_link_audit.html +++ /dev/null @@ -1,80 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} - -{% block main_panel %} -{% trans "Hi," %}
{% blocktrans %} - {{ shared_from }} has shared a library with you. - Please click here to verify your email. + {{ shared_from }} shared a file link with you. +{% endblocktrans%} +
++{% blocktrans %} +You can click here to verify your email address and visit it. {% endblocktrans%}
- {% endautoescape %} - +{% endblock %} + +{% block thanks %} {% endblock %} diff --git a/seahub/share/templates/share/share_link_email_audit.html b/seahub/share/templates/share/share_link_email_audit.html index bd5f21a43c..5cfd264a61 100644 --- a/seahub/share/templates/share/share_link_email_audit.html +++ b/seahub/share/templates/share/share_link_email_audit.html @@ -1,82 +1,112 @@ {% extends "base.html" %} {% load i18n %} +{% block sub_title %}{% trans "Email address verification" %} - {% endblock %} +{% block header_css_class %}hide{% endblock %} +{% block extra_base_style %} + +{% endblock %} + +{% block extra_style %} + +{% endblock %} + {% block main_panel %} -