mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-11-09 20:00:12 +00:00
Compare commits
No commits in common. "4aae6551808988f3e3e6cf2dcfda3aea41086a68" and "fdc97b4e86cca328ea7154db43499eada5e38598" have entirely different histories.
4aae655180
...
fdc97b4e86
28
.drone.yml
28
.drone.yml
@ -45,31 +45,3 @@ steps:
|
|||||||
BUILDRONE_KEY:
|
BUILDRONE_KEY:
|
||||||
from_secret: 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">
|
<div class="modal-content card">
|
||||||
<span class="heading mb-1">{{ .lang.successHeader }}</span>
|
<span class="heading mb-1">{{ .lang.successHeader }}</span>
|
||||||
<p class="content mb-1">{{ .successMessage }}</p>
|
<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>
|
</div>
|
||||||
<div id="notification-box"></div>
|
<div id="notification-box"></div>
|
||||||
@ -53,9 +53,7 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{{ if .contactMessage }}
|
|
||||||
<aside class="col aside sm ~info">{{ .contactMessage }}</aside>
|
<aside class="col aside sm ~info">{{ .contactMessage }}</aside>
|
||||||
{{ end }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"validationStrings": {
|
"validationStrings": {
|
||||||
"length": {
|
"length": {
|
||||||
"singular": "Must have at least {n} character",
|
"singular": "Must have at least {n} character",
|
||||||
"plural": "Must have at least {n} characters"
|
"plural": "Must have a least {n} characters"
|
||||||
},
|
},
|
||||||
"uppercase": {
|
"uppercase": {
|
||||||
"singular": "Must have at least {n} uppercase character",
|
"singular": "Must have at least {n} uppercase character",
|
||||||
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
10
pwval.go
10
pwval.go
@ -8,11 +8,13 @@ import (
|
|||||||
type Validator struct {
|
type Validator struct {
|
||||||
minLength, upper, lower, number, special int
|
minLength, upper, lower, number, special int
|
||||||
criteria ValidatorConf
|
criteria ValidatorConf
|
||||||
|
specialChars []rune
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValidatorConf map[string]int
|
type ValidatorConf map[string]int
|
||||||
|
|
||||||
func (vd *Validator) init(criteria ValidatorConf) {
|
func (vd *Validator) init(criteria ValidatorConf) {
|
||||||
|
vd.specialChars = []rune{'[', '@', '_', '!', '#', '$', '%', '^', '&', '*', '(', ')', '<', '>', '?', '/', '\\', '|', '}', '{', '~', ':', ']'}
|
||||||
vd.criteria = criteria
|
vd.criteria = criteria
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,8 +40,12 @@ func (vd *Validator) validate(password string) map[string]bool {
|
|||||||
count["lowercase"] += 1
|
count["lowercase"] += 1
|
||||||
} else if unicode.IsNumber(c) {
|
} else if unicode.IsNumber(c) {
|
||||||
count["number"] += 1
|
count["number"] += 1
|
||||||
} else if unicode.ToUpper(c) == unicode.ToLower(c) {
|
} else {
|
||||||
count["special"] += 1
|
for _, s := range vd.specialChars {
|
||||||
|
if c == s {
|
||||||
|
count["special"] += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results := map[string]bool{}
|
results := map[string]bool{}
|
||||||
|
35
ts/form.ts
35
ts/form.ts
@ -27,7 +27,7 @@ declare var window: formWindow;
|
|||||||
var defaultPwValStrings: pwValStrings = {
|
var defaultPwValStrings: pwValStrings = {
|
||||||
length: {
|
length: {
|
||||||
singular: "Must have at least {n} character",
|
singular: "Must have at least {n} character",
|
||||||
plural: "Must have at least {n} characters"
|
plural: "Must have a least {n} characters"
|
||||||
},
|
},
|
||||||
uppercase: {
|
uppercase: {
|
||||||
singular: "Must have at least {n} uppercase character",
|
singular: "Must have at least {n} uppercase character",
|
||||||
@ -117,7 +117,7 @@ form.onsubmit = create;
|
|||||||
|
|
||||||
class Requirement {
|
class Requirement {
|
||||||
private _name: string;
|
private _name: string;
|
||||||
protected _minCount: number;
|
private _minCount: number;
|
||||||
private _content: HTMLSpanElement;
|
private _content: HTMLSpanElement;
|
||||||
private _valid: HTMLSpanElement;
|
private _valid: HTMLSpanElement;
|
||||||
private _li: HTMLLIElement;
|
private _li: HTMLLIElement;
|
||||||
@ -151,13 +151,8 @@ class Requirement {
|
|||||||
}
|
}
|
||||||
this._content.textContent = text;
|
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 testStrings = (f: pwValString): boolean => {
|
||||||
const testString = (s: string): boolean => {
|
const testString = (s: string): boolean => {
|
||||||
if (s == "" || !s.includes("{n}")) { return false; }
|
if (s == "" || !s.includes("{n}")) { return false; }
|
||||||
@ -166,32 +161,6 @@ const testStrings = (f: pwValString): boolean => {
|
|||||||
return testString(f.singular) && testString(f.plural);
|
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} = {};
|
var requirements: { [category: string]: Requirement} = {};
|
||||||
|
|
||||||
if (!window.validationStrings) {
|
if (!window.validationStrings) {
|
||||||
|
Loading…
Reference in New Issue
Block a user