mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-28 03:50:10 +00:00
Compare commits
5 Commits
fdc97b4e86
...
4aae655180
Author | SHA1 | Date | |
---|---|---|---|
4aae655180 | |||
6860933498 | |||
|
377c8d3e4e | ||
|
74bbfdf5c2 | ||
0171fb8569 |
28
.drone.yml
28
.drone.yml
@ -45,3 +45,31 @@ steps:
|
||||
BUILDRONE_KEY:
|
||||
from_secret: BUILDRONE_KEY
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
---
|
||||
name: jfa-go-pr
|
||||
kind: pipeline
|
||||
type: docker
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:latest
|
||||
commands:
|
||||
- apt update -y
|
||||
- apt install build-essential python3-pip curl software-properties-common sed upx -y
|
||||
- (curl -sL https://deb.nodesource.com/setup_14.x | bash -)
|
||||
- apt install nodejs
|
||||
- curl -sL https://git.io/goreleaser > goreleaser.sh
|
||||
- chmod +x goreleaser.sh
|
||||
- ./goreleaser.sh --snapshot --skip-publish --rm-dist
|
||||
|
||||
trigger:
|
||||
event:
|
||||
include:
|
||||
- pull_request
|
||||
|
@ -10,7 +10,7 @@
|
||||
<div class="modal-content card">
|
||||
<span class="heading mb-1">{{ .lang.successHeader }}</span>
|
||||
<p class="content mb-1">{{ .successMessage }}</p>
|
||||
<span class="button ~urge !normal full-width center supra submit" id="create-success-button">{{ .lang.successContinueButton }}</span>
|
||||
<a class="button ~urge !normal full-width center supra submit" href="{{ .jfLink }}" id="create-success-button">{{ .lang.successContinueButton }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="notification-box"></div>
|
||||
@ -53,7 +53,9 @@
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ if .contactMessage }}
|
||||
<aside class="col aside sm ~info">{{ .contactMessage }}</aside>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -18,7 +18,7 @@
|
||||
"validationStrings": {
|
||||
"length": {
|
||||
"singular": "Must have at least {n} character",
|
||||
"plural": "Must have a least {n} characters"
|
||||
"plural": "Must have at least {n} characters"
|
||||
},
|
||||
"uppercase": {
|
||||
"singular": "Must have at least {n} uppercase character",
|
||||
|
41
lang/form/nl-nl.json
Normal file
41
lang/form/nl-nl.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Nederlands (NL)"
|
||||
},
|
||||
"strings": {
|
||||
"pageTitle": "Maak Jellyfin account aan",
|
||||
"createAccountHeader": "Account aanmaken",
|
||||
"accountDetails": "Details",
|
||||
"emailAddress": "Email",
|
||||
"username": "Gebruikersnaam",
|
||||
"password": "Wachtwoord",
|
||||
"reEnterPassword": "Bevestig wachtwoord",
|
||||
"reEnterPasswordInvalid": "Wachtwoorden komen niet overeen.",
|
||||
"createAccountButton": "Maak account aan",
|
||||
"passwordRequirementsHeader": "Wachtwoordvereisten",
|
||||
"successHeader": "Succes!",
|
||||
"successContinueButton": "Doorgaan",
|
||||
"validationStrings": {
|
||||
"length": {
|
||||
"singular": "Moet ten minste {n} teken bevatten",
|
||||
"plural": "Moet ten minste {n} tekens bevatten"
|
||||
},
|
||||
"uppercase": {
|
||||
"singular": "Moet ten minste {n} hoofdletter bevatten",
|
||||
"plural": "Moet ten minste {n} hoofdletters bevatten"
|
||||
},
|
||||
"lowercase": {
|
||||
"singular": "Moet ten minste {n} kleine letter bevatten",
|
||||
"plural": "Moet ten minste {n} kleine letters bevatten"
|
||||
},
|
||||
"number": {
|
||||
"singular": "Moet ten minste {n} cijfer bevatten",
|
||||
"plural": "Moet ten minste {n} cijfers bevatten"
|
||||
},
|
||||
"special": {
|
||||
"singular": "Moet ten minste {n} bijzonder teken bevatten",
|
||||
"plural": "Moet ten minste {n} bijzondere tekens bevatten"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
10
pwval.go
10
pwval.go
@ -8,13 +8,11 @@ import (
|
||||
type Validator struct {
|
||||
minLength, upper, lower, number, special int
|
||||
criteria ValidatorConf
|
||||
specialChars []rune
|
||||
}
|
||||
|
||||
type ValidatorConf map[string]int
|
||||
|
||||
func (vd *Validator) init(criteria ValidatorConf) {
|
||||
vd.specialChars = []rune{'[', '@', '_', '!', '#', '$', '%', '^', '&', '*', '(', ')', '<', '>', '?', '/', '\\', '|', '}', '{', '~', ':', ']'}
|
||||
vd.criteria = criteria
|
||||
}
|
||||
|
||||
@ -40,12 +38,8 @@ func (vd *Validator) validate(password string) map[string]bool {
|
||||
count["lowercase"] += 1
|
||||
} else if unicode.IsNumber(c) {
|
||||
count["number"] += 1
|
||||
} else {
|
||||
for _, s := range vd.specialChars {
|
||||
if c == s {
|
||||
count["special"] += 1
|
||||
}
|
||||
}
|
||||
} else if unicode.ToUpper(c) == unicode.ToLower(c) {
|
||||
count["special"] += 1
|
||||
}
|
||||
}
|
||||
results := map[string]bool{}
|
||||
|
35
ts/form.ts
35
ts/form.ts
@ -27,7 +27,7 @@ declare var window: formWindow;
|
||||
var defaultPwValStrings: pwValStrings = {
|
||||
length: {
|
||||
singular: "Must have at least {n} character",
|
||||
plural: "Must have a least {n} characters"
|
||||
plural: "Must have at least {n} characters"
|
||||
},
|
||||
uppercase: {
|
||||
singular: "Must have at least {n} uppercase character",
|
||||
@ -117,7 +117,7 @@ form.onsubmit = create;
|
||||
|
||||
class Requirement {
|
||||
private _name: string;
|
||||
private _minCount: number;
|
||||
protected _minCount: number;
|
||||
private _content: HTMLSpanElement;
|
||||
private _valid: HTMLSpanElement;
|
||||
private _li: HTMLLIElement;
|
||||
@ -151,8 +151,13 @@ class Requirement {
|
||||
}
|
||||
this._content.textContent = text;
|
||||
}
|
||||
|
||||
validate = (count: number) => { this.valid = (count >= this._minCount); }
|
||||
}
|
||||
|
||||
// Incredible code right here
|
||||
const isInt = (s: string): boolean => { return (s in ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]); }
|
||||
|
||||
const testStrings = (f: pwValString): boolean => {
|
||||
const testString = (s: string): boolean => {
|
||||
if (s == "" || !s.includes("{n}")) { return false; }
|
||||
@ -161,6 +166,32 @@ const testStrings = (f: pwValString): boolean => {
|
||||
return testString(f.singular) && testString(f.plural);
|
||||
}
|
||||
|
||||
interface Validation { [name: string]: number }
|
||||
|
||||
const validate = (s: string): Validation => {
|
||||
let v: Validation = {};
|
||||
for (let criteria of ["length", "lowercase", "uppercase", "number", "special"]) { v[criteria] = 0; }
|
||||
v["length"] = s.length;
|
||||
for (let c of s) {
|
||||
if (isInt(c)) { v["number"]++; }
|
||||
else {
|
||||
const upper = c.toUpperCase();
|
||||
if (upper == c.toLowerCase()) { v["special"]++; }
|
||||
else {
|
||||
if (upper == c) { v["uppercase"]++; }
|
||||
else if (upper != c) { v["lowercase"]++; }
|
||||
}
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
passwordField.addEventListener("keyup", () => {
|
||||
const v = validate(passwordField.value);
|
||||
for (let criteria in requirements) {
|
||||
requirements[criteria].validate(v[criteria]);
|
||||
}
|
||||
});
|
||||
|
||||
var requirements: { [category: string]: Requirement} = {};
|
||||
|
||||
if (!window.validationStrings) {
|
||||
|
Loading…
Reference in New Issue
Block a user