1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-09-19 19:00:11 +00:00

Compare commits

..

No commits in common. "4aae6551808988f3e3e6cf2dcfda3aea41086a68" and "fdc97b4e86cca328ea7154db43499eada5e38598" have entirely different histories.

6 changed files with 12 additions and 108 deletions

View File

@ -45,31 +45,3 @@ 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

View File

@ -10,7 +10,7 @@
<div class="modal-content card">
<span class="heading mb-1">{{ .lang.successHeader }}</span>
<p class="content mb-1">{{ .successMessage }}</p>
<a class="button ~urge !normal full-width center supra submit" href="{{ .jfLink }}" id="create-success-button">{{ .lang.successContinueButton }}</a>
<span class="button ~urge !normal full-width center supra submit" id="create-success-button">{{ .lang.successContinueButton }}</span>
</div>
</div>
<div id="notification-box"></div>
@ -53,9 +53,7 @@
{{ end }}
</ul>
</div>
{{ if .contactMessage }}
<aside class="col aside sm ~info">{{ .contactMessage }}</aside>
{{ end }}
</div>
</div>
</div>

View File

@ -18,7 +18,7 @@
"validationStrings": {
"length": {
"singular": "Must have at least {n} character",
"plural": "Must have at least {n} characters"
"plural": "Must have a least {n} characters"
},
"uppercase": {
"singular": "Must have at least {n} uppercase character",

View File

@ -1,41 +0,0 @@
{
"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"
}
}
}
}

View File

@ -8,11 +8,13 @@ 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
}
@ -38,8 +40,12 @@ func (vd *Validator) validate(password string) map[string]bool {
count["lowercase"] += 1
} else if unicode.IsNumber(c) {
count["number"] += 1
} else if unicode.ToUpper(c) == unicode.ToLower(c) {
count["special"] += 1
} else {
for _, s := range vd.specialChars {
if c == s {
count["special"] += 1
}
}
}
}
results := map[string]bool{}

View File

@ -27,7 +27,7 @@ declare var window: formWindow;
var defaultPwValStrings: pwValStrings = {
length: {
singular: "Must have at least {n} character",
plural: "Must have at least {n} characters"
plural: "Must have a least {n} characters"
},
uppercase: {
singular: "Must have at least {n} uppercase character",
@ -117,7 +117,7 @@ form.onsubmit = create;
class Requirement {
private _name: string;
protected _minCount: number;
private _minCount: number;
private _content: HTMLSpanElement;
private _valid: HTMLSpanElement;
private _li: HTMLLIElement;
@ -151,13 +151,8 @@ 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; }
@ -166,32 +161,6 @@ 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) {