Mercurial > moin-2.0-moinboot
changeset 2146:2459cbb053af default tip
Merged thomaswaldmann/moin-2.0 into default
| author | Radomir Dopieralski <bitbucket@sheep.art.pl> |
|---|---|
| date | Tue, 23 Jul 2013 15:24:24 +0200 |
| parents | 391452f7bae5 (current diff) 78ed0ce6b718 (diff) |
| children | |
| files | |
| diffstat | 8 files changed, 57 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py Wed Jul 10 16:10:43 2013 +0200 +++ b/MoinMoin/apps/frontend/views.py Tue Jul 23 15:24:24 2013 +0200 @@ -1137,12 +1137,29 @@ if 'username' in request.values and 'token' in request.values: u = user.User(auth_username=request.values['username']) token = request.values['token'] - if u and u.disabled and token and u.validate_recovery_token(token): - u.profile[DISABLED] = False + success = False + if u and token and u.validate_recovery_token(token): + unvalidated_email = u.profile[EMAIL_UNVALIDATED] + if (app.cfg.user_email_unique and + user.search_users(**{EMAIL: unvalidated_email})): + msg = _('This email is already in use.') + else: + if u.disabled: + u.profile[DISABLED] = False + msg = _('Your account has been activated, you can log in now.') + else: + msg = _('Your new email address has been confirmed.') + u.profile[EMAIL] = unvalidated_email + del u.profile[EMAIL_UNVALIDATED] + del u.profile[RECOVERPASS_KEY] + success = True + else: + msg = _('Your username and/or token is invalid!') + if success: u.save() - flash(_("Your account has been activated, you can log in now."), "info") + flash(msg, 'info') else: - flash(_('Your username and/or token is invalid!'), "error") + flash(msg, 'error') return redirect(url_for('.show_root')) @@ -1508,21 +1525,19 @@ flaskg.user.profile[k] = v if (part == 'notification' and app.cfg.user_email_verification and form['email'].value != user_old_email): - # disable account - flaskg.user.profile[DISABLED] = True + flaskg.user.profile[EMAIL] = user_old_email + flaskg.user.profile[EMAIL_UNVALIDATED] = form['email'].value # send verification mail is_ok, msg = flaskg.user.mail_email_verification() if is_ok: - flaskg.user.logout_session() - response['flash'].append((_('Your account has been disabled because you changed your ' - 'email address. Please see the email we sent to your ' - 'address to reactivate it.'), "info")) + response['flash'].append( + (_('A confirmation email has been sent to your ' + 'newly configured email address.'), "info")) response['redirect'] = url_for('.show_root') else: - # sending the verification email didn't work. reset email change and alert the user. - flaskg.user.profile[DISABLED] = False - flaskg.user.profile[EMAIL] = user_old_email - flaskg.user.save() + # sending the verification email didn't work. + # delete the unvalidated email and alert the user. + del flaskg.user.profile[EMAIL_UNVALIDATED] response['flash'].append((_('Your email address was not changed because sending the ' 'verification email failed. Please try again later.'), "error"))
--- a/MoinMoin/config/default.py Wed Jul 10 16:10:43 2013 +0200 +++ b/MoinMoin/config/default.py Tue Jul 23 15:24:24 2013 +0200 @@ -502,6 +502,7 @@ RESULTS_PER_PAGE: 0, LOCALE: None, # None -> do browser language detection, otherwise just use this locale TIMEZONE: None, # None -> use cfg.timezone_default + EMAIL_UNVALIDATED: None, }, 'Default attributes of the user object'), )), # ==========================================================================
--- a/MoinMoin/constants/keys.py Wed Jul 10 16:10:43 2013 +0200 +++ b/MoinMoin/constants/keys.py Tue Jul 23 15:24:24 2013 +0200 @@ -71,7 +71,7 @@ QUICKLINKS = u"quicklinks" SESSION_KEY = u"session_key" SESSION_TOKEN = u"session_token" -RECOVERPASS_KEY = u"recoverpass_key" +RECOVERPASS_KEY = u"recoverpass_key" # TODO: this is used for email confirmation as well, maybe it needs better name EDIT_ON_DOUBLECLICK = u"edit_on_doubleclick" SCROLL_PAGE_AFTER_EDIT = u"scroll_page_after_edit" SHOW_COMMENTS = u"show_comments" @@ -82,6 +82,7 @@ WANT_TRIVIAL = u"want_trivial" EMAIL_SUBSCRIBED_EVENTS = u"email_subscribed_events" DISABLED = u"disabled" +EMAIL_UNVALIDATED = u"email_unvalidated" # in which backend is some revision stored? BACKENDNAME = u"backendname"
--- a/MoinMoin/converter/_tests/test_docbook_in.py Wed Jul 10 16:10:43 2013 +0200 +++ b/MoinMoin/converter/_tests/test_docbook_in.py Tue Jul 23 15:24:24 2013 +0200 @@ -256,13 +256,13 @@ def test_link(self): data = [ # Normal link, with conversion of all the xlink attributes - ('<article><para><link xlink:href="uri:test" xlink:title="title">link</link></para></article>', - # <page><body><div html:class="article"><p><a xlink:href="uri:test" xlink:title="title">link</a></p></div></body></page> - '/page/body/div/p/a[@xlink:href="uri:test"][@xlink:title="title"][text()="link"]'), + ('<article><para><link xlink:href="http:test" xlink:title="title">link</link></para></article>', + # <page><body><div html:class="article"><p><a xlink:href="http:test" xlink:title="title">link</a></p></div></body></page> + '/page/body/div/p/a[@xlink:href="http:test"][@xlink:title="title"][text()="link"]'), # Old link from DocBook v.4.X for backward compatibility - ('<article><para><ulink url="url:test">link</ulink></para></article>', - # <page><body><div html:class="article"><p><a xlink:href="url:test">link</a></p></div></body></page> - '/page/body/div/p/a[@xlink:href="url:test"][text()="link"]'), + ('<article><para><ulink url="http:test">link</ulink></para></article>', + # <page><body><div html:class="article"><p><a xlink:href="http:test">link</a></p></div></body></page> + '/page/body/div/p/a[@xlink:href="http:test"][text()="link"]'), # Normal link, with linkend attribute ('<article><para><link linkend="anchor">link</link></para></article>', # <page><body><div html:class="article"><p><a xlink:href="#anchor">link</a></p></div></body></page> @@ -273,8 +273,10 @@ '/page/body/div/p/a[@xlink:href="uri#anchor"][text()="link"]'), # Link w/ javascript: scheme ('<article><para><ulink url="javascript:alert(\'xss\')">link</ulink></para></article>', - # <page><body><div html:class="article"><p><a xlink:href="url:test">link</a></p></div></body></page> - '/page/body/div/p/a[@xlink:href=""][text()="link"]'), + # the href attribute will default to None because javascript is not an allowed url scheme + # we don't care how it gets rendered as long as the javascript doesn't show up + # <page><body><div html:class="article"><p><a xlink:href="None">link</a></p></div></body></page> + '/page/body/div/p/a[@xlink:href="None"][text()="link"]'), ] for i in data: yield (self.do, ) + i
--- a/MoinMoin/items/__init__.py Wed Jul 10 16:10:43 2013 +0200 +++ b/MoinMoin/items/__init__.py Tue Jul 23 15:24:24 2013 +0200 @@ -396,6 +396,8 @@ def modify(self, meta, data, comment=u'', contenttype_guessed=None, **update_meta): meta = dict(meta) # we may get a read-only dict-like, copy it + # get rid of None values + update_meta = {key:value for key, value in update_meta.items() if value is not None} meta.update(update_meta) return self._save(meta, data, contenttype_guessed=contenttype_guessed, comment=comment)
--- a/MoinMoin/items/_tests/test_Item.py Wed Jul 10 16:10:43 2013 +0200 +++ b/MoinMoin/items/_tests/test_Item.py Tue Jul 23 15:24:24 2013 +0200 @@ -362,6 +362,7 @@ update_meta = { 'another_test_key': 'updated_test_value', 'new_test_key': 'new_test_value', + 'none_test_key': None, } item.modify(another_meta, another_data, **update_meta) item = Item.create(name) @@ -369,6 +370,7 @@ assert item.meta['test_key'] == another_meta['test_key'] assert item.meta['another_test_key'] == update_meta['another_test_key'] assert item.meta['new_test_key'] == update_meta['new_test_key'] + assert 'none_test_key' not in item.meta coverage_modules = ['MoinMoin.items']
--- a/MoinMoin/templates/mail/account_verification.txt Wed Jul 10 16:10:43 2013 +0200 +++ b/MoinMoin/templates/mail/account_verification.txt Tue Jul 23 15:24:24 2013 +0200 @@ -1,10 +1,11 @@ {{ _("""\ -Somebody has created an account with this email address. +An account with this email address has been created or +an existing account has been changed to use this email address. Please use the link below to verify your email address: %(link)s -If you didn't create this account, please ignore this email. +Please ignore this email if you didn't initiate this action. -""", link=link) }} \ No newline at end of file +""", link=link) }}
--- a/MoinMoin/user.py Wed Jul 10 16:10:43 2013 +0200 +++ b/MoinMoin/user.py Tue Jul 23 15:24:24 2013 +0200 @@ -81,8 +81,9 @@ if validate and email and app.cfg.user_email_unique: if search_users(email=email): return _("This email already belongs to somebody else.") - - theuser.profile[EMAIL] = email + theuser.profile[EMAIL_UNVALIDATED] = email + else: + theuser.profile[EMAIL] = email # Openid should be unique if validate and openid and search_users(openid=openid): @@ -786,5 +787,8 @@ subject = _('[%(sitename)s] Please verify your email address', sitename=self._cfg.sitename or "Wiki") - mailok, msg = sendmail.sendmail(subject, text, to=[self.email], mail_from=self._cfg.mail_from) + email = self.profile[EMAIL_UNVALIDATED] + mailok, msg = sendmail.sendmail(subject, text, to=[email], mail_from=self._cfg.mail_from) return mailok, msg + + self._mail_email_verification(email=self.email)
