Changeset - de9a3152c206
[Not reviewed]
default
0 2 0
Mads Kiilerich - 10 years ago 2015-07-31 15:44:07
madski@unity3d.com
auth: disable password change when not using internal auth
2 files changed with 14 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/my_account.py
Show inline comments
 
@@ -146,25 +146,29 @@ class MyAccountController(BaseController
 
                        % form_result.get('username'), category='error')
 
        if update:
 
            return redirect('my_account')
 
        return htmlfill.render(
 
            render('admin/my_account/my_account.html'),
 
            defaults=defaults,
 
            encoding="UTF-8",
 
            force_defaults=False)
 

	
 
    def my_account_password(self):
 
        c.active = 'password'
 
        self.__load_data()
 
        if request.POST:
 

	
 
        managed_fields = auth_modules.get_managed_fields(c.user)
 
        c.can_change_password = 'password' not in managed_fields
 

	
 
        if request.POST and c.can_change_password:
 
            _form = PasswordChangeForm(self.authuser.username)()
 
            try:
 
                form_result = _form.to_python(request.POST)
 
                UserModel().update(self.authuser.user_id, form_result)
 
                Session().commit()
 
                h.flash(_("Successfully updated password"), category='success')
 
            except formencode.Invalid as errors:
 
                return htmlfill.render(
 
                    render('admin/my_account/my_account.html'),
 
                    defaults=errors.value,
 
                    errors=errors.error_dict or {},
 
                    prefix_error=False,
kallithea/templates/admin/my_account/my_account_password.html
Show inline comments
 
<div style="font-size: 20px; color: #666666; padding: 0px 0px 10px 0px">${_('Change Your Account Password')}</div>
 

	
 
%if c.can_change_password:
 

	
 
${h.form(url('my_account_password'), method='post')}
 
<div class="form">
 
    <div class="fields">
 
     <div class="field">
 
        <div class="label">
 
            <label for="current_password">${_('Current password')}:</label>
 
        </div>
 
        <div class="input">
 
            ${h.password('current_password',class_='medium')}
 
        </div>
 
     </div>
 

	
 
@@ -27,12 +30,18 @@ ${h.form(url('my_account_password'), met
 
        <div class="input">
 
            ${h.password('new_password_confirmation',class_='medium')}
 
        </div>
 
     </div>
 

	
 
        <div class="buttons">
 
          ${h.submit('save',_('Save'),class_="btn")}
 
          ${h.reset('reset',_('Reset'),class_="btn")}
 
        </div>
 
    </div>
 
</div>
 
${h.end_form()}
 

	
 
%else:
 

	
 
${_('This account is managed with %s and the password cannot be changed here') % c.user.extern_type}
 

	
 
%endif
0 comments (0 inline, 0 general)