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

Compare commits

..

5 Commits

Author SHA1 Message Date
4aae655180
live validation on form, change special character definition
The internal array of special characters was lacking, so a character is
now special when not a digit and (uppercase form) == (lowercase form).
2021-01-09 01:00:27 +00:00
6860933498
functional continue button in form, hide empty contactMessage box 2021-01-09 00:07:19 +00:00
alexh-name
377c8d3e4e fix typo in form/en-us 2021-01-08 23:58:48 +00:00
Richard de Boer
74bbfdf5c2 add dutch translation of account creation form 2021-01-08 23:57:18 +00:00
0171fb8569
dont attempt to release PRs on buildrone 2021-01-08 23:52:36 +00:00
6 changed files with 108 additions and 12 deletions

View File

@ -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

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>
<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>

View File

@ -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
View 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"
}
}
}
}

View File

@ -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,14 +38,10 @@ 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 {
} else if unicode.ToUpper(c) == unicode.ToLower(c) {
count["special"] += 1
}
}
}
}
results := map[string]bool{}
for criterion, num := range count {
if num < vd.criteria[criterion] {

View File

@ -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) {