def render_password_change_not_allowed(self, ctx, data): username = self.get_logged_in_username() user_rdf = uihelpers.find_user(username) if user_rdf is None: return ctx.tag else: return ''
def render_multiple_connections_ok(self, ctx, data): username = self.get_logged_in_username() if (uihelpers.find_user(username) is not None) and ( uihelpers.get_user_fixed_ip(username) is None): return ctx.tag else: return ''
def submitted(self, ctx, form, data): fda = formalutils.FormDataAccessor(form, [], ctx).descend('changepassword') if fda.has_key('pw2') and fda.has_key('pw3') and (fda['pw2'] != fda['pw3']): fda.add_error('pw2', 'Passwords do not match') fda.add_error('pw3', 'Passwords do not match') # verify old password username = self.get_logged_in_username() user_rdf = uihelpers.find_user(username) if user_rdf is None: # presumably RADIUS user fda.add_error('pw1', 'Password change not allowed') else: if fda.has_key('pw1') and ( not uihelpers.check_username_and_password( username, fda['pw1'])): fda.add_error('pw1', 'Password incorrect') # prevent password change if marker exists; this is useful for demo server if os.path.exists(constants.NOPWCHANGE_MARKERFILE): _log.info('nopwchange marker exists, not changing password') fda.add_error('pw1', 'Password change not allowed') # finalize validation fda.finalize_validation() # XXX: does admin need control here? i.e., prevent changing of password? # ok, we're happy; change the password _log.info('changing password for user %s' % username) uihelpers.change_user_password(username, fda['pw2']) # restart radius server with new config; no need to nuke connections here because # no users are added or removed. try: pd = uidatahelpers.CreateProtocolData() pd.save_protocol_data(use_current_config=True) pd.activate_protocol_data(use_current_config=True) pd.restart_freeradius() # needs protocol config in place except: _log.exception('cannot restart freeradius, ignoring') # redirect request = inevow.IRequest(ctx) request.redirect(request.URLPath().sibling('passwordchanged.html')) request.finish() return ''
def submitted(self, ctx, form, data): fda = formalutils.FormDataAccessor(form, [], ctx).descend('changepassword') if fda.has_key('pw2') and fda.has_key('pw3') and (fda['pw2'] != fda['pw3']): fda.add_error('pw2', 'Passwords do not match') fda.add_error('pw3', 'Passwords do not match') # verify old password username = self.get_logged_in_username() user_rdf = uihelpers.find_user(username) if user_rdf is None: # presumably RADIUS user fda.add_error('pw1', 'Password change not allowed') else: if fda.has_key('pw1') and (not uihelpers.check_username_and_password(username, fda['pw1'])): fda.add_error('pw1', 'Password incorrect') # prevent password change if marker exists; this is useful for demo server if os.path.exists(constants.NOPWCHANGE_MARKERFILE): _log.info('nopwchange marker exists, not changing password') fda.add_error('pw1', 'Password change not allowed') # finalize validation fda.finalize_validation() # XXX: does admin need control here? i.e., prevent changing of password? # ok, we're happy; change the password _log.info('changing password for user %s' % username) uihelpers.change_user_password(username, fda['pw2']) # restart radius server with new config; no need to nuke connections here because # no users are added or removed. try: pd = uidatahelpers.CreateProtocolData() pd.save_protocol_data(use_current_config=True) pd.activate_protocol_data(use_current_config=True) pd.restart_freeradius() # needs protocol config in place except: _log.exception('cannot restart freeradius, ignoring') # redirect request = inevow.IRequest(ctx) request.redirect(request.URLPath().sibling('passwordchanged.html')) request.finish() return ''
def render_multiple_connections_not_known(self, ctx, data): username = self.get_logged_in_username() if uihelpers.find_user(username) is None: return ctx.tag else: return ''
def render_multiple_connections_not_ok(self, ctx, data): username = self.get_logged_in_username() if (uihelpers.find_user(username) is not None) and (uihelpers.get_user_fixed_ip(username) is not None): return ctx.tag else: return ''