diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2011-06-01 20:32:01 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2011-06-01 20:32:33 -0400 |
commit | 63d4df420fa8174716f4bf8da761c608cf968310 (patch) | |
tree | e9c2d3da4b2a52e82ded7104a24cd31f0e3c910b | |
parent | 4be3d56d82f19f64181847e565dd4c742a35e3ef (diff) | |
download | askbot-63d4df420fa8174716f4bf8da761c608cf968310.tar.gz askbot-63d4df420fa8174716f4bf8da761c608cf968310.tar.bz2 askbot-63d4df420fa8174716f4bf8da761c608cf968310.zip |
added possibility to disable login method management by the users in the user policy settings and fixed a bug in the removal of login methods
-rw-r--r-- | askbot/conf/user_settings.py | 9 | ||||
-rw-r--r-- | askbot/deps/django_authopenid/views.py | 6 | ||||
-rw-r--r-- | askbot/skins/default/templates/authopenid/signin.html | 68 | ||||
-rw-r--r-- | askbot/skins/default/templates/user_profile/user_info.html | 2 |
4 files changed, 50 insertions, 35 deletions
diff --git a/askbot/conf/user_settings.py b/askbot/conf/user_settings.py index 45d29355..77afa23b 100644 --- a/askbot/conf/user_settings.py +++ b/askbot/conf/user_settings.py @@ -29,6 +29,15 @@ settings.register( ) settings.register( + livesettings.BooleanValue( + USER_SETTINGS, + 'ALLOW_ADD_REMOVE_LOGIN_METHODS', + default = True, + description = _('Allow adding and removing login methods') + ) +) + +settings.register( livesettings.IntegerValue( USER_SETTINGS, 'MIN_USERNAME_LENGTH', diff --git a/askbot/deps/django_authopenid/views.py b/askbot/deps/django_authopenid/views.py index cb5994c4..740dcaf8 100644 --- a/askbot/deps/django_authopenid/views.py +++ b/askbot/deps/django_authopenid/views.py @@ -280,6 +280,10 @@ def signin( next_url = get_next_url(request) logging.debug('next url is %s' % next_url) + if askbot_settings.ALLOW_ADD_REMOVE_LOGIN_METHODS == False \ + and request.user.is_authenticated(): + return HttpResponseRedirect(next_url) + if next_url == reverse('user_signin'): next_url = '%(next)s?next=%(next)s' % {'next': next_url} @@ -580,6 +584,8 @@ def show_signin_view( @login_required def delete_login_method(request): + if askbot_settings.ALLOW_ADD_REMOVE_LOGIN_METHODS == False: + raise Http404 if request.is_ajax() and request.method == 'POST': provider_name = request.POST['provider_name'] try: diff --git a/askbot/skins/default/templates/authopenid/signin.html b/askbot/skins/default/templates/authopenid/signin.html index 9133fa9c..4cbd905a 100644 --- a/askbot/skins/default/templates/authopenid/signin.html +++ b/askbot/skins/default/templates/authopenid/signin.html @@ -125,41 +125,41 @@ {% endif %}
</fieldset>
{% endif %}
- {% if user.is_authenticated() and existing_login_methods %}
- <div
- id='existing-login-methods'
- {% if login_form.password_change_failed %}
- style="display:none";
- {% endif %}
- >
- <h2 id='ab-show-login-methods'>
- {% trans %}Here are your current login methods{% endtrans %}
- </h2>
- <table id='ab-existing-login-methods'>
- <tr>
- <th>{% trans %}provider{% endtrans %}</th>
- <th>{% trans %}last used{% endtrans %}</th>
- <th>{% trans %}delete, if you like{% endtrans %}</th>
- </tr>
- {% for login_method in existing_login_methods %}
- <tr class="ab-provider-row">
- <td class="ab-provider-name">
- {{login_method.provider_name}}
- </td>
- <td>
- {% if login_method.last_used_timestamp %}
- {{login_method.last_used_timestamp|diff_date}}
- {% endif %}
- </td>
- <td>
- <button>{% trans %}delete{% endtrans %}</button>
- </td>
- </tr>
- {% endfor %}
- </table>
- </div>
- {% endif %}
</form>
+ {% if user.is_authenticated() and existing_login_methods and settings.ALLOW_ADD_REMOVE_LOGIN_METHODS %}
+ <div
+ id='existing-login-methods'
+ {% if login_form.password_change_failed %}
+ style="display:none";
+ {% endif %}
+ >
+ <h2 id='ab-show-login-methods'>
+ {% trans %}Here are your current login methods{% endtrans %}
+ </h2>
+ <table id='ab-existing-login-methods'>
+ <tr>
+ <th>{% trans %}provider{% endtrans %}</th>
+ <th>{% trans %}last used{% endtrans %}</th>
+ <th>{% trans %}delete, if you like{% endtrans %}</th>
+ </tr>
+ {% for login_method in existing_login_methods %}
+ <tr class="ab-provider-row">
+ <td class="ab-provider-name">
+ {{login_method.provider_name}}
+ </td>
+ <td>
+ {% if login_method.last_used_timestamp %}
+ {{login_method.last_used_timestamp|diff_date}}
+ {% endif %}
+ </td>
+ <td>
+ <button>{% trans %}delete{% endtrans %}</button>
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+ {% endif %}
{% endif %}
{% if view_subtype != 'email_sent' or view_subtype == 'bad_key' %}
{% if user.is_anonymous() and settings.ALLOW_ACCOUNT_RECOVERY_BY_EMAIL %}
diff --git a/askbot/skins/default/templates/user_profile/user_info.html b/askbot/skins/default/templates/user_profile/user_info.html index 5aa5c094..a9c50a13 100644 --- a/askbot/skins/default/templates/user_profile/user_info.html +++ b/askbot/skins/default/templates/user_profile/user_info.html @@ -35,7 +35,7 @@ <a href="{% url edit_user view_user.id %}"> {% trans %}update profile{% endtrans %} </a> - {% if request.user == view_user %} + {% if request.user == view_user and settings.ALLOW_ADD_REMOVE_LOGIN_METHODS %} | <a href="{% url user_signin %}?next={% url user_signin %}"> {% trans %}manage login methods{% endtrans %} </a> |