def __init__(self, errormsg, request=None, details=None): localvars = {} localvars['errormsg'] = html_escape(errormsg) if details: localvars['details'] = html_escape(details) formatted = evaluate('error.html', localvars) Response.__init__(self, formatted)
def showAddForm(self, req, username, email, fullname, errormsg=''): localvars = {} localvars['errormsg'] = errormsg localvars['username'] = username localvars['email'] = email localvars['fullname'] = fullname formatted = evaluate_main('newuser.html', localvars, request=req) return Response(formatted)
def showAddForm(self, req, reposname, errormsg=''): templatevars = {} templatevars['errormsg'] = errormsg templatevars['repository'] = reposname templatevars["systems"] = vcs_list() formatted = evaluate_main('newrepository.html', templatevars, request=req) return Response(formatted)
def evaluate_form(self, msg='', session=None): localvalues = {} localvalues['msg'] = msg localvalues['base_url'] = options.url_path('base_url_submin') if session and 'user' in session and 'is_authenticated' in session['user']: if session['user']['is_authenticated']: localvalues['is_authenticated'] = True localvalues['username'] = session['user']['name'] return Response(evaluate('login.html', localvalues))
def handler(self, req, path): localvars = {} if not req.session['user']['is_admin']: base_url = options.url_path('base_url_submin') username = req.session['user']['name'] return Redirect(base_url + '/users/show/' + username, req) formatted = evaluate_main('intro.html', localvars, request=req) return Response(formatted)
def handler(self, request, path): if 'auto_authenticate' in request.session: username = request.session['auto_authenticate'] else: if not request.post: return self.evaluate_form(session=request.session) username = request.post.get('username', '') password = request.post.get('password', '') if '' in (username, password): return self.evaluate_form(session=request.session) invalid_login = True u = None try: u = user.User(username) invalid_login = False except UnknownUserError as e: pass if 'auto_authenticate' in request.session: del request.session['auto_authenticate'] request.session['change_password_hint'] = True else: try: if not u or not u.check_password(password): return self.evaluate_form( 'Not a valid username and password combination') except NoMD5PasswordError as e: return self.evaluate_form(str(e)) if invalid_login: return self.evaluate_form( 'Not a valid username and password combination') if not database_isuptodate(): localvalues = {} request.session['upgrade_user'] = True base_url = options.url_path('base_url_submin') localvalues['base_url'] = str(base_url) localvalues['session_user'] = u return Response(evaluate('database_upgrade.html', localvalues)) url = options.url_path('base_url_submin') if 'redirected_from' in request.session: login_url = options.url_path('base_url_submin') + 'login' url = request.session['redirected_from'] if url.startswith(login_url): url = options.url_path('base_url_submin') session_user = u.session_object() session_user['is_authenticated'] = True request.session['user'] = session_user request.session.cleanup() return Redirect(url, request, store_url=False)
def handler(self, req, path): if req.is_ajax(): return Response('Invalid') if len(path) > 0: username = path[0] if len(path) > 1: key = path[1] return self.reset_password(req, username, key) return self.send_email(req, path)
def handler(self, req, path): localvars = {} diagnostics = {} diagnostics.update(trac.diagnostics()) diagnostics.update(svn.diagnostics()) diagnostics.update(git.diagnostics()) diagnostics.update(email.diagnostics()) localvars['diag'] = diagnostics localvars['subminenv'] = options.env_path() formatted = evaluate_main('diagnostics.html', localvars, request=req) return Response(formatted)
def handler(self, req, path): localvars = {} localvars['uptodated'] = True localvars['base_url'] = options.url_path('base_url_submin') if database_isuptodate(): localvars['alreadyuptodate'] = True else: database_evolve() localvars['alreadyuptodate'] = False formatted = evaluate('database_upgrade.html', localvars) return Response(formatted)
def send_email(self, req, path): templatevars = { 'base_url': options.url_path('base_url_submin') } username = req.post.get('username', '') if username: try: u = user.User(username) u.prepare_password_reset(req.remote_address) templatevars['sent'] = True except UnknownUserError: templatevars['sent'] = True else: templatevars['form'] = True formatted = evaluate('password.html', templatevars) return Response(formatted)
def show(self, req, vcs_type, path, templatevars): import os.path u = user.User(req.session['user']['name']) try: repos = Repository(path[0], vcs_type) # Lie if user has no permission to read if not u.is_admin and not repository.userHasReadPermissions( u.name, path[0], vcs_type): raise DoesNotExistError except DoesNotExistError: return ErrorResponse('This repository does not exist.', request=req) trac_enabled = options.value('enabled_trac', 'no') != 'no' if trac_enabled: templatevars['trac_config_ok'] = True templatevars['trac_exists'] = False try: if trac.exists(path[0]): templatevars['trac_exists'] = True except MissingConfig as e: templatevars['trac_config_ok'] = False templatevars['trac_msg'] = \ 'There is something missing in your config: %s' % str(e) trac_base_url = options.url_path('base_url_trac') trac_http_url = str(trac_base_url + repos.name) templatevars['trac_http_url'] = trac_http_url try: vcs_url = repos.url() except MissingConfig as e: vcs_url = "" templatevars['vcs_url_error'] = str(e) templatevars['vcs_url'] = vcs_url templatevars['repository'] = repos templatevars['vcs_type'] = vcs_type formatted = evaluate_main('repositories.html', templatevars, request=req) return Response(formatted)
def reset_password(self, req, username, key): templatevars = { 'base_url': options.url_path('base_url_submin') } if 'auto_authenticate' in req.session: del req.session['auto_authenticate'] try: u = user.User(username) except UnknownUserError: raise if not u.valid_password_reset_key(key): templatevars['invalid'] = True else: templatevars['reset'] = True req.session['auto_authenticate'] = username u.clear_password_reset_key() formatted = evaluate('password.html', templatevars) return Response(formatted)
def show(self, req, path, localvars): if len(path) < 1: return ErrorResponse('Invalid path', request=req) is_admin = req.session['user']['is_admin'] try: g = group.Group(path[0]) except (IndexError, UnknownGroupError): if not is_admin: return ErrorResponse('Not permitted', request=req) return ErrorResponse('This group does not exist.', request=req) if not is_admin and req.session['user']['name'] not in g.members(): return ErrorResponse('Not permitted', request=req) localvars['group'] = g formatted = evaluate_main('groups.html', localvars, request=req) return Response(formatted)
def show(self, req, path, localvars): if len(path) < 1: return ErrorResponse('Invalid path', request=req) is_admin = req.session['user']['is_admin'] if not is_admin and path[0] != req.session['user']['name']: raise Unauthorized('Permission denied to view this user') try: u = user.User(path[0]) except (IndexError, UnknownUserError): return ErrorResponse('This user does not exist.', request=req) localvars['user'] = u if 'change_password_hint' in req.session: localvars['change_password_hint'] = True p = list(permissions.list_by_user(u.name)) localvars['permissions'] = p localvars['enabled_git'] = 'git' in options.value('vcs_plugins', '') localvars['external'] = u.is_external formatted = evaluate_main('users.html', localvars, request=req) return Response(formatted)
def showAddForm(self, req, groupname, errormsg=''): localvars = {} localvars['errormsg'] = errormsg localvars['groupname'] = groupname formatted = evaluate_main('newgroup.html', localvars, request=req) return Response(formatted)