Compare commits
3 commits
489d64414e
...
b4ab4809c6
Author | SHA1 | Date | |
---|---|---|---|
b4ab4809c6 | |||
cdf977f0db | |||
a86e47113c |
6 changed files with 46 additions and 14 deletions
4
Ideen.md
4
Ideen.md
|
@ -1,6 +1,5 @@
|
|||
# MUSS
|
||||
|
||||
- api: admin Login case sensitivity (username "admin" == "AdMiN")
|
||||
- api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild)
|
||||
- api: Config-Option "Überspringe leere Türchen" (standard ja)
|
||||
|
||||
|
@ -8,7 +7,6 @@
|
|||
|
||||
- api/ui: Türchen mit Tag "0" einem zufälligen Tag zuweisen
|
||||
- api/?: Option "custom Zuordnung Buchstaben" (standard leer)
|
||||
- api: `config.solution` - whitespace="IGNORE"->"REMOVE" umbenennen, +Sonderzeichen
|
||||
- ui: `confirm` durch bulma Komponente(n) ersetzen
|
||||
|
||||
# Erledigt
|
||||
|
@ -20,3 +18,5 @@
|
|||
- Option "Leerzeichen ignorieren" (standard ja)
|
||||
- Nach einigen Sekunden: Meldung "Türchen anzeigen?"
|
||||
- `alert` durch bulma Komponente(n) ersetzen
|
||||
- api: admin Login case sensitivity (username "admin" == "AdMiN")
|
||||
- api: `config.solution` - whitespace="IGNORE"->"REMOVE" umbenennen, +Sonderzeichen
|
||||
|
|
|
@ -23,10 +23,18 @@ class TransformedString(BaseModel):
|
|||
# Leerzeichen an Anfang und Ende entfernen
|
||||
STRIP = "STRIP"
|
||||
|
||||
# whitespace entfernen
|
||||
IGNORE = "IGNORE"
|
||||
# whitespace durch Leerzeichen ersetzen
|
||||
SPACE = "SPACE"
|
||||
|
||||
# special chars
|
||||
# whitespace entfernen
|
||||
REMOVE = "REMOVE"
|
||||
|
||||
class __SpecialChars(str, Enum):
|
||||
# unverändert
|
||||
KEEP = "KEEP"
|
||||
|
||||
# Sonderzeichen entfernen
|
||||
REMOVE = "REMOVE"
|
||||
|
||||
class __Case(str, Enum):
|
||||
# unverändert
|
||||
|
@ -43,7 +51,8 @@ class TransformedString(BaseModel):
|
|||
|
||||
value: str
|
||||
|
||||
whitespace: __Whitespace = __Whitespace.IGNORE
|
||||
whitespace: __Whitespace = __Whitespace.REMOVE
|
||||
special_chars: __SpecialChars = __SpecialChars.REMOVE
|
||||
case: __Case = __Case.UPPER
|
||||
|
||||
@field_validator("whitespace", "case", mode="before")
|
||||
|
@ -54,21 +63,28 @@ class TransformedString(BaseModel):
|
|||
def clean(self) -> str:
|
||||
result = self.value
|
||||
|
||||
# Whitespace bearbeiten
|
||||
if self.whitespace is self.__Whitespace.STRIP:
|
||||
# Whitespace verarbeiten
|
||||
if self.whitespace is TransformedString.__Whitespace.STRIP:
|
||||
result = result.strip()
|
||||
|
||||
elif self.whitespace is self.__Whitespace.IGNORE:
|
||||
elif self.whitespace is TransformedString.__Whitespace.SPACE:
|
||||
result = re.sub(string=result, pattern=r"\s+", repl=" ")
|
||||
|
||||
elif self.whitespace is TransformedString.__Whitespace.REMOVE:
|
||||
result = re.sub(string=result, pattern=r"\s+", repl="")
|
||||
|
||||
# Sonderzeichen verarbeiten
|
||||
if self.special_chars is TransformedString.__SpecialChars.REMOVE:
|
||||
result = re.sub(string=result, pattern=r"[^a-zA-Z0-9\s]+", repl="")
|
||||
|
||||
# Groß-/Kleinschreibung verarbeiten
|
||||
if self.case is self.__Case.UPPER:
|
||||
if self.case is TransformedString.__Case.UPPER:
|
||||
result = result.upper()
|
||||
|
||||
elif self.case is self.__Case.LOWER:
|
||||
elif self.case is TransformedString.__Case.LOWER:
|
||||
result = result.lower()
|
||||
|
||||
elif self.case is self.__Case.RANDOM:
|
||||
elif self.case is TransformedString.__Case.RANDOM:
|
||||
rnd = Random(self.value)
|
||||
|
||||
def randomcase(c: str) -> str:
|
||||
|
|
|
@ -19,8 +19,14 @@ async def user_is_admin(
|
|||
True iff der user "admin" ist
|
||||
"""
|
||||
|
||||
username_correct = secrets.compare_digest(credentials.username, cfg.admin.name)
|
||||
password_correct = secrets.compare_digest(credentials.password, cfg.admin.password)
|
||||
username_correct = secrets.compare_digest(
|
||||
credentials.username.lower(),
|
||||
cfg.admin.name.lower(),
|
||||
)
|
||||
password_correct = secrets.compare_digest(
|
||||
credentials.password,
|
||||
cfg.admin.password,
|
||||
)
|
||||
|
||||
return username_correct and password_correct
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ class AdminConfigModel(BaseModel):
|
|||
class __Solution(BaseModel):
|
||||
value: str
|
||||
whitespace: str
|
||||
special_chars: str
|
||||
case: str
|
||||
clean: str
|
||||
|
||||
|
@ -81,6 +82,7 @@ async def get_config_model(
|
|||
"solution": {
|
||||
"value": cfg.solution.value,
|
||||
"whitespace": cfg.solution.whitespace,
|
||||
"special_chars": cfg.solution.special_chars,
|
||||
"case": cfg.solution.case,
|
||||
"clean": cfg.solution.clean,
|
||||
},
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
{{ admin_config_model.solution.whitespace }}
|
||||
</span>
|
||||
</dd>
|
||||
<dd>
|
||||
Sonderzeichen:
|
||||
<span class="is-uppercase is-family-monospace">
|
||||
{{ admin_config_model.solution.special_chars }}
|
||||
</span>
|
||||
</dd>
|
||||
<dd>
|
||||
Buchstaben:
|
||||
<span class="is-uppercase is-family-monospace">
|
||||
|
@ -184,6 +190,7 @@ export default class extends Vue {
|
|||
solution: {
|
||||
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
whitespace: "KEEP",
|
||||
special_chars: "KEEP",
|
||||
case: "KEEP",
|
||||
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
},
|
||||
|
|
|
@ -2,6 +2,7 @@ export interface AdminConfigModel {
|
|||
solution: {
|
||||
value: string;
|
||||
whitespace: string;
|
||||
special_chars: string;
|
||||
case: string;
|
||||
clean: string;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue