mirror of https://github.com/CIRCL/lookyloo
fix: function name
parent
1ea95a6362
commit
7b06ce399b
|
@ -53,7 +53,7 @@ else:
|
||||||
all_timezones_set = available_timezones()
|
all_timezones_set = available_timezones()
|
||||||
|
|
||||||
from .genericapi import api as generic_api
|
from .genericapi import api as generic_api
|
||||||
from .helpers import (User, valid_username, build_users_table, get_secret_key,
|
from .helpers import (User, is_valid_username, build_users_table, get_secret_key,
|
||||||
load_user_from_request, src_request_ip, sri_load,
|
load_user_from_request, src_request_ip, sri_load,
|
||||||
get_lookyloo_instance)
|
get_lookyloo_instance)
|
||||||
from .proxied import ReverseProxied
|
from .proxied import ReverseProxied
|
||||||
|
@ -107,7 +107,7 @@ def login() -> WerkzeugResponse | str | Response:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
username = request.form['username']
|
username = request.form['username']
|
||||||
if not valid_username(username):
|
if not is_valid_username(username):
|
||||||
flash('User is not permitted.', 'error')
|
flash('User is not permitted.', 'error')
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
users_table = build_users_table()
|
users_table = build_users_table()
|
||||||
|
@ -1640,7 +1640,7 @@ def capture_web() -> str | Response | WerkzeugResponse:
|
||||||
@flask_login.login_required # type: ignore[misc]
|
@flask_login.login_required # type: ignore[misc]
|
||||||
def simple_capture() -> str | Response | WerkzeugResponse:
|
def simple_capture() -> str | Response | WerkzeugResponse:
|
||||||
user = flask_login.current_user.get_id()
|
user = flask_login.current_user.get_id()
|
||||||
if not re.match("^[A-Za-z0-9]+$", user):
|
if not is_valid_username(user):
|
||||||
# Username has been manipulated
|
# Username has been manipulated
|
||||||
flash('User is not permitted.', 'error')
|
flash('User is not permitted.', 'error')
|
||||||
return redirect(url_for('submit_capture'))
|
return redirect(url_for('submit_capture'))
|
||||||
|
|
|
@ -5,6 +5,7 @@ from __future__ import annotations
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ def load_user_from_request(request: Request) -> User | None:
|
||||||
return user
|
return user
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def valid_username(username: str) -> bool:
|
def is_valid_username(username: str) -> bool:
|
||||||
return re.match("^[A-Za-z0-9]+$", username)
|
return re.match("^[A-Za-z0-9]+$", username)
|
||||||
|
|
||||||
@lru_cache(64)
|
@lru_cache(64)
|
||||||
|
|
Loading…
Reference in New Issue