def process_request(self, req): data = {'accountldap_message': None} template = '%s.html' % self.MODULE_NAME if req.method != 'POST': return template, data, None p1 = req.args.get('password1') p2 = req.args.get('password2') old = req.args.get('oldpassword') if p1 != p2: data['accountldap_message'] = tag.center( u'Las contraseñas suministradas no coinciden.', tag.b(u' Por favor, revise las contraseñas.'), style='color:chocolate') return template, data, None if old == p1: data['accountldap_message'] = tag.center( u'Las contraseña antigua y la nueva contraseña es la misma.', tag.b( u' Por favor, realice un cambio en la nueva contraseña.'), style='color:chocolate') return template, data, None dn = '%s=%s,%s,%s' % (self.userFilter, req.authname, self.userdn, self.basedn) try: self.log.warn('Ldap change password dn. %s' % dn) self.ldap.passwd_s(dn, old, p1) except ldap.LDAPError, e: data['accountldap_message'] = tag.center( u'Se produjo un error durante el cambio de contraseña.', tag. b(u' Por favor, comprueba que la contraseña antigua es la correcta.' ), style='color:chocolate') self.log.warn('Ldap change password. %s' % e) return template, data, None
def process_request(self, req): data = {'accountldap_message': None} template = '%s.html' % self.MODULE_NAME if req.method != 'POST': return template, data, None p1 = req.args.get('password1') p2 = req.args.get('password2') old = req.args.get('oldpassword') if p1 != p2: data['accountldap_message'] = tag.center( u'The passwords do not match.', tag.b(u' Please enter the same password twice.'), style='color:chocolate') return template, data, None if old == p1: data['accountldap_message'] = tag.center( u'The old password is the same as the new password.', tag.b(u' Please supply a different password.'), style='color:chocolate') return template, data, None dn = req.session['dn'] try: # Establish binding with the authenticated user's credentials self.ldap.simple_bind_s(dn, old) self.log.warn('Ldap change password dn. %s' % dn) # Update password self.ldap.passwd_s(dn, old, p1) except ldap.LDAPError, e: data['accountldap_message'] = \ tag.center(u'There was an error changing your password.', tag.b(u' Please make sure the old password you' ' entered was correct.'), style='color:chocolate') self.log.warn('Ldap change password. %s' % e) return template, data, None
def handle_repo_paths(self, req): repopath = req.args.get('q') if not repopath.startswith('/'): repopath = '/%s' % repopath repos = self.env.get_repository(req.authname) def get_node_entries(path): # Should probably try to cache these searches, # although only meant for admins if not path.startswith('/'): path = '/%s' % path fallback = posixpath.dirname(path) try: node = repos.get_node(str(path), repos.youngest_rev) except (TracError, NoSuchNode): node = repos.get_node(fallback, repos.youngest_rev) node_entries = list(node.get_entries()) entries = [] for entry in node_entries: path = entry.path if not path.startswith('/'): path = '/%s' % path if path.startswith(repopath): # Only return those that we're interested in entries.append(entry) entries.sort(key=attrgetter('path')) return entries entries = get_node_entries(repopath) if not entries: req.write(tag.center( tag.em(_("No matches found on repository for "), tag.b(repopath)) )) raise RequestDone while len(entries) <= 1: # If returning only one entry, return a file no matter how deep if entries[0].kind == 'dir': entries = get_node_entries(entries[0].path) elif entries[0].kind == 'file': break req.write('<ul>') for entry in entries: path = entry.path if not path.startswith('/'): path = '/%s' % path req.write(tag.li(tag.b(repopath), tag(path.split(repopath)[1]))) req.write('</ul>') raise RequestDone
def handle_locales(self, req): query = req.args.get('q') if not query: req.write(tag.center(tag.em(_('No matches')))) raise RequestDone matches = [AVAILABLE_LOCALES[l] for l in AVAILABLE_LOCALES.keys() if l.lower().startswith(query.lower())] if not matches: req.write(tag.center(tag.em(_("No matches found for locale "), tag.b(query)))) raise RequestDone req.write('<ul>') for loc, eng_name, disp_name in matches: req.write(tag.li(tag.b(loc), tag.br, tag.em(disp_name), tag.br, tag.em(eng_name), realvalue=loc)) req.write('</ul>') raise RequestDone
def process_request(self, req): data = {'accountldap_message': None} template = '%s.html' % self.MODULE_NAME if req.method != 'POST': return template, data, None p1 = req.args.get('password1') p2 = req.args.get('password2') old = req.args.get('oldpassword') if p1 != p2: data['accountldap_message'] = tag.center(u'Las contraseñas suministradas no coinciden.', tag.b(u' Por favor, revise las contraseñas.'), style='color:chocolate') return template, data, None if old == p1: data['accountldap_message'] = tag.center(u'Las contraseña antigua y la nueva contraseña es la misma.', tag.b(u' Por favor, realice un cambio en la nueva contraseña.'), style='color:chocolate') return template, data, None dn = '%s=%s,%s,%s' % (self.userFilter, req.authname, self.userdn, self.basedn) try: self.log.warn('Ldap change password dn. %s' % dn) self.ldap.passwd_s(dn, old, p1) except ldap.LDAPError, e: data['accountldap_message'] = tag.center(u'Se produjo un error durante el cambio de contraseña.', tag.b(u' Por favor, comprueba que la contraseña antigua es la correcta.'), style='color:chocolate') self.log.warn('Ldap change password. %s' % e) return template, data, None
dn = '%s=%s,%s,%s' % (self.userFilter, req.authname, self.userdn, self.basedn) try: self.log.warn('Ldap change password dn. %s' % dn) self.ldap.passwd_s(dn, old, p1) except ldap.LDAPError, e: data['accountldap_message'] = tag.center( u'Se produjo un error durante el cambio de contraseña.', tag. b(u' Por favor, comprueba que la contraseña antigua es la correcta.' ), style='color:chocolate') self.log.warn('Ldap change password. %s' % e) return template, data, None data['accountldap_message'] = tag.center( tag.b(u'La contraseña se ha cambiado correctamente.'), style='color:green') return template, data, None # #---------------------------------------------- ITemplateProvider interface # def get_htdocs_dirs(self): return [] def get_templates_dirs(self): from pkg_resources import resource_filename return [resource_filename(__name__, 'templates')] # #----------------------------------------------------------- helper methods
try: # Establish binding with the authenticated user's credentials self.ldap.simple_bind_s(dn, old) self.log.warn('Ldap change password dn. %s' % dn) # Update password self.ldap.passwd_s(dn, old, p1) except ldap.LDAPError, e: data['accountldap_message'] = \ tag.center(u'There was an error changing your password.', tag.b(u' Please make sure the old password you' ' entered was correct.'), style='color:chocolate') self.log.warn('Ldap change password. %s' % e) return template, data, None data['accountldap_message'] = \ tag.center(tag.b(u'Your LDAP password has been updated successfully.'), style='color:green') return template, data, None # #---------------------------------------------- ITemplateProvider interface # def get_htdocs_dirs(self): return [] def get_templates_dirs(self): from pkg_resources import resource_filename return [resource_filename(__name__, 'templates')] # #----------------------------------------------------------- helper methods #
old = req.args.get('oldpassword') if p1 != p2: data['accountldap_message'] = tag.center(u'Las contraseñas suministradas no coinciden.', tag.b(u' Por favor, revise las contraseñas.'), style='color:chocolate') return template, data, None if old == p1: data['accountldap_message'] = tag.center(u'Las contraseña antigua y la nueva contraseña es la misma.', tag.b(u' Por favor, realice un cambio en la nueva contraseña.'), style='color:chocolate') return template, data, None dn = '%s=%s,%s,%s' % (self.userFilter, req.authname, self.userdn, self.basedn) try: self.log.warn('Ldap change password dn. %s' % dn) self.ldap.passwd_s(dn, old, p1) except ldap.LDAPError, e: data['accountldap_message'] = tag.center(u'Se produjo un error durante el cambio de contraseña.', tag.b(u' Por favor, comprueba que la contraseña antigua es la correcta.'), style='color:chocolate') self.log.warn('Ldap change password. %s' % e) return template, data, None data['accountldap_message'] = tag.center(tag.b(u'La contraseña se ha cambiado correctamente.'), style='color:green') return template, data, None # #---------------------------------------------- ITemplateProvider interface # def get_htdocs_dirs(self): return [] def get_templates_dirs(self): from pkg_resources import resource_filename return [resource_filename(__name__, 'templates')] # #----------------------------------------------------------- helper methods # def _getUserAttributes(self, uid): """Devuelve el nombre completo y el correo definido en el ldap