mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-20 01:49:20 +01:00
Compare commits
71 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6fc5765f3 | ||
|
|
62cbbf57e7 | ||
|
|
b81c5636cc | ||
|
|
d867649a93 | ||
|
|
cd08259012 | ||
|
|
e814af1af5 | ||
|
|
ecbff16a88 | ||
|
|
baffa4a38c | ||
|
|
fad507d2dd | ||
|
|
053ee8284d | ||
|
|
4f05fa9375 | ||
|
|
7ecf1bcf94 | ||
|
|
f030cdcb02 | ||
|
|
7474a1868e | ||
|
|
9a4d90790a | ||
|
|
7e38ee07c7 | ||
|
|
b9574e2d67 | ||
|
|
6431613363 | ||
|
|
a00392166c | ||
|
|
bfcad6c5f2 | ||
|
|
7daf2162ef | ||
|
|
dec8d75083 | ||
|
|
f486f8de1d | ||
|
|
93b1e9c371 | ||
|
|
6440f57467 | ||
|
|
25451eb763 | ||
|
|
dbefb80f63 | ||
|
|
889d68dc7b | ||
|
|
42dbc04ff9 | ||
|
|
82c8ef1e4b | ||
|
|
4deb45df3c | ||
|
|
4b02960fd1 | ||
|
|
15e5564b12 | ||
|
|
e66241ddcb | ||
|
|
d3990a6c55 | ||
|
|
be1d081629 | ||
|
|
fafb524a47 | ||
|
|
da1b9ccac7 | ||
|
|
7b97e1ca26 | ||
|
|
7f11549337 | ||
|
|
987e0ddd4e | ||
|
|
8fd097836f | ||
|
|
5acee68987 | ||
|
|
25a1ca5a9f | ||
|
|
32af107699 | ||
|
|
b929e16f2c | ||
|
|
1c942186aa | ||
|
|
d9f8785372 | ||
|
|
8758d74e32 | ||
|
|
6448a7db9e | ||
|
|
46d1da7cd3 | ||
|
|
77c05a4d4f | ||
|
|
4024334c0c | ||
|
|
3294b27029 | ||
|
|
0d4747e8e9 | ||
|
|
1ebc648158 | ||
|
|
7e5bfd4b10 | ||
|
|
5074f4d7af | ||
|
|
22feec49cb | ||
|
|
4b59876d8b | ||
|
|
3c278bc930 | ||
|
|
0221d29ecb | ||
|
|
130b56f02d | ||
|
|
e86f5f4c3c | ||
|
|
3b0701e772 | ||
|
|
9874dce520 | ||
|
|
7ff492df6c | ||
|
|
51b59ae103 | ||
|
|
8888807780 | ||
|
|
d19f7d6b53 | ||
|
|
07de4e5015 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -21,7 +21,7 @@ What to do to reproduce the problem.
|
||||
|
||||
**If you're using a build with a tray icon, right-click on it and press "Open logs" to access your logs.**
|
||||
|
||||
When you notice the problem, check the output of `jfa-go`. If the problem is not obvious (e.g a panic (red text) or 'ERROR' log), re-run jfa-go with the `-debug` argument and reproduce the problem. You should then take a screenshot of the output, or paste it here, preferably between \`\`\` tags (e.g \`\`\``Log here`\`\`\`). Remember to censor any personal information.
|
||||
When you notice the problem, check the output of `jfa-go` or get the logs by pressing the "Logs" button in the Settings tab. If the problem is not obvious (e.g a panic (red text) or 'ERROR' log), re-run jfa-go with the `-debug` argument and reproduce the problem. You should then take a screenshot of the output, or paste it here, preferably between \`\`\` tags (e.g \`\`\``Log here`\`\`\`). Remember to censor any personal information.
|
||||
|
||||
|
||||
If nothing catches your eye in the log, access the admin page via your browser, go into the console (Right click > Inspect Element > Console), refresh, reproduce the problem then paste the output here in the same way as above.
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
node_modules/
|
||||
site/node_modules/
|
||||
site/out/
|
||||
site/tempts/
|
||||
mail/*.html
|
||||
dist/
|
||||
build/
|
||||
|
||||
@@ -13,33 +13,42 @@ before:
|
||||
- npm install
|
||||
- npm install esbuild
|
||||
- mkdir -p data/web/css
|
||||
- npx esbuild --bundle css/base.css --outfile=./data/web/css/bundle.css --external:remixicon.css --minify
|
||||
- cp node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 data/web/css/
|
||||
- cp -r html data/
|
||||
- node scripts/missing-colors.js html data/html
|
||||
- cp -r lang data/
|
||||
- cp LICENSE data/
|
||||
- cp jfa-go.service data/
|
||||
- python3 scripts/enumerate_config.py -i config/config-base.json -o data/config-base.json
|
||||
- python3 scripts/generate_ini.py -i config/config-base.json -o data/config-default.ini
|
||||
- python3 scripts/compile_mjml.py -o data/
|
||||
- npx esbuild --bundle ts/admin.ts --outfile=./data/web/js/admin.js --minify
|
||||
- npx esbuild --bundle ts/pwr.ts --outfile=./data/web/js/pwr.js --minify
|
||||
- npx esbuild --bundle ts/form.ts --outfile=./data/web/js/form.js --minify
|
||||
- npx esbuild --bundle ts/setup.ts --outfile=./data/web/js/setup.js --minify
|
||||
- npx esbuild --bundle ts/crash.ts --outfile=./data/crash.js --minify
|
||||
- rm -rf tempts
|
||||
- cp -r ts tempts
|
||||
- scripts/dark-variant.sh tempts
|
||||
- scripts/dark-variant.sh tempts/modules
|
||||
- npx esbuild --bundle tempts/admin.ts --outfile=./data/web/js/admin.js --minify
|
||||
- npx esbuild --bundle tempts/pwr.ts --outfile=./data/web/js/pwr.js --minify
|
||||
- npx esbuild --bundle tempts/form.ts --outfile=./data/web/js/form.js --minify
|
||||
- npx esbuild --bundle tempts/setup.ts --outfile=./data/web/js/setup.js --minify
|
||||
- npx esbuild --bundle tempts/crash.ts --outfile=./data/crash.js --minify
|
||||
- rm -r tempts
|
||||
- npx esbuild --bundle css/base.css --outfile=./data/web/css/bundle.css --external:remixicon.css --minify
|
||||
- cp html/crash.html data/
|
||||
- npx uncss data/crash.html --csspath web/css --output data/bundle.css
|
||||
- npx tailwindcss -i data/web/css/bundle.css -o data/bundle.css --content "html/crash.html"
|
||||
- node scripts/inline.js root data data/crash.html data/crash.html
|
||||
- rm data/bundle.css
|
||||
- npx tailwindcss -i data/web/css/bundle.css -o data/web/css/bundle.css
|
||||
- mv data/crash.html data/html/
|
||||
- go get -u github.com/swaggo/swag/cmd/swag
|
||||
- swag init -g main.go
|
||||
- mv data/web/css/bundle.css data/web/css/{{.Env.JFA_GO_CSS_VERSION}}bundle.css
|
||||
builds:
|
||||
- id: notray
|
||||
dir: ./
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater=binary
|
||||
- -s -w -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater=binary -X main.cssVersion={{.Env.JFA_GO_CSS_VERSION}}
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
@@ -56,7 +65,7 @@ builds:
|
||||
flags:
|
||||
- -tags=tray
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater=binary -H=windowsgui
|
||||
- -s -w -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater=binary -X main.cssVersion={{.Env.JFA_GO_CSS_VERSION}} -H=windowsgui
|
||||
goos:
|
||||
- windows
|
||||
goarch:
|
||||
@@ -68,7 +77,7 @@ builds:
|
||||
flags:
|
||||
- -tags=tray
|
||||
ldflags:
|
||||
- -s -w -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater=binary
|
||||
- -s -w -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater=binary -X main.cssVersion={{.Env.JFA_GO_CSS_VERSION}}
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
|
||||
@@ -4,9 +4,9 @@ COPY . /opt/build
|
||||
|
||||
RUN apt-get update -y \
|
||||
&& apt-get install build-essential python3-pip curl software-properties-common sed -y \
|
||||
&& (curl -sL https://deb.nodesource.com/setup_14.x | bash -) \
|
||||
&& (curl -sL https://deb.nodesource.com/setup_current.x | bash -) \
|
||||
&& apt-get install nodejs \
|
||||
&& (cd /opt/build; make configuration npm email typescript bundle-css inline swagger copy INTERNAL=off GOESBUILD=on) \
|
||||
&& (cd /opt/build; make configuration npm email typescript variants-html bundle-css inline-css swagger copy INTERNAL=off GOESBUILD=on) \
|
||||
&& sed -i 's#id="password_resets-watch_directory" placeholder="/config/jellyfin"#id="password_resets-watch_directory" value="/jf" disabled#g' /opt/build/build/data/html/setup.html
|
||||
|
||||
|
||||
|
||||
15
Makefile
15
Makefile
@@ -6,12 +6,14 @@ else
|
||||
endif
|
||||
GOBINARY ?= go
|
||||
|
||||
CSSVERSION ?= v3
|
||||
|
||||
VERSION ?= $(shell git describe --exact-match HEAD 2> /dev/null || echo vgit)
|
||||
VERSION := $(shell echo $(VERSION) | sed 's/v//g')
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD || echo unknown)
|
||||
|
||||
UPDATER ?= off
|
||||
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT)
|
||||
LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.cssVersion=$(CSSVERSION)
|
||||
ifeq ($(UPDATER), on)
|
||||
LDFLAGS := $(LDFLAGS) -X main.updater=binary
|
||||
else ifneq ($(UPDATER), off)
|
||||
@@ -52,7 +54,7 @@ ifeq ($(DEBUG), on)
|
||||
SOURCEMAP := --sourcemap
|
||||
TYPECHECK := tsc -noEmit --project ts/tsconfig.json
|
||||
# jank
|
||||
COPYTS := rm -r $(DATA)/web/js/ts; cp -r tempts $(DATA)/web/js
|
||||
COPYTS := rm -r $(DATA)/web/js/ts; cp -r tempts $(DATA)/web/js/ts
|
||||
UNCSS := cp $(DATA)/web/css/bundle.css $(DATA)/bundle.css
|
||||
TAILWIND := --content ""
|
||||
else
|
||||
@@ -97,8 +99,8 @@ typescript:
|
||||
$(adding dark variants to typescript)
|
||||
-rm -r tempts
|
||||
cp -r ts tempts
|
||||
scripts/dark-variant.sh ts tempts
|
||||
scripts/dark-variant.sh ts tempts/modules
|
||||
scripts/dark-variant.sh tempts
|
||||
scripts/dark-variant.sh tempts/modules
|
||||
$(info compiling typescript)
|
||||
-mkdir -p $(DATA)/web/js
|
||||
-$(ESBUILD) --bundle tempts/admin.ts $(SOURCEMAP) --outfile=./$(DATA)/web/js/admin.js --minify
|
||||
@@ -129,7 +131,7 @@ bundle-css:
|
||||
npx tailwindcss -i $(DATA)/web/css/bundle.css -o $(DATA)/web/css/bundle.css $(TAILWIND)
|
||||
# npx postcss -o $(DATA)/web/css/bundle.css $(DATA)/web/css/bundle.css
|
||||
|
||||
inline:
|
||||
inline-css:
|
||||
cp html/crash.html $(DATA)/crash.html
|
||||
$(UNCSS)
|
||||
node scripts/inline.js root $(DATA) $(DATA)/crash.html $(DATA)/crash.html
|
||||
@@ -154,6 +156,7 @@ copy:
|
||||
$(info copying language files)
|
||||
cp -r lang $(DATA)/
|
||||
cp LICENSE $(DATA)/
|
||||
mv $(DATA)/web/css/bundle.css $(DATA)/web/css/$(CSSVERSION)bundle.css
|
||||
|
||||
# internal-files:
|
||||
# python3 scripts/embed.py internal
|
||||
@@ -174,4 +177,4 @@ clean:
|
||||
-rm docs/docs.go docs/swagger.json docs/swagger.yaml
|
||||
go clean
|
||||
|
||||
all: configuration npm email typescript variants-html bundle-css inline swagger copy compile
|
||||
all: configuration npm email typescript variants-html bundle-css inline-css swagger copy compile
|
||||
|
||||
179
api.go
179
api.go
@@ -368,6 +368,15 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc
|
||||
success = false
|
||||
return
|
||||
}
|
||||
err := app.discord.ApplyRole(discordUser.ID)
|
||||
if err != nil {
|
||||
f = func(gc *gin.Context) {
|
||||
app.err.Printf("%s: New user failed: Failed to set member role: %v", req.Code, err)
|
||||
respond(401, "error", gc)
|
||||
}
|
||||
success = false
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
var matrixUser MatrixUser
|
||||
@@ -504,9 +513,11 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc
|
||||
}
|
||||
}
|
||||
id := user.ID
|
||||
var profile Profile
|
||||
if invite.Profile != "" {
|
||||
app.debug.Printf("Applying settings from profile \"%s\"", invite.Profile)
|
||||
profile, ok := app.storage.profiles[invite.Profile]
|
||||
var ok bool
|
||||
profile, ok = app.storage.profiles[invite.Profile]
|
||||
if !ok {
|
||||
profile = app.storage.profiles["Default"]
|
||||
}
|
||||
@@ -527,17 +538,6 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc
|
||||
app.err.Printf("%s: Failed to set configuration template (%d): %v", req.Code, status, err)
|
||||
}
|
||||
}
|
||||
if app.config.Section("ombi").Key("enabled").MustBool(false) {
|
||||
if profile.Ombi != nil && len(profile.Ombi) != 0 {
|
||||
errors, code, err := app.ombi.NewUser(req.Username, req.Password, req.Email, profile.Ombi)
|
||||
if err != nil || code != 200 {
|
||||
app.info.Printf("Failed to create Ombi user (%d): %s", code, err)
|
||||
app.debug.Printf("Errors reported by Ombi: %s", strings.Join(errors, ", "))
|
||||
} else {
|
||||
app.info.Println("Created Ombi user")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if app.config.Section("password_resets").Key("enabled").MustBool(false) {
|
||||
if req.Email != "" {
|
||||
@@ -587,6 +587,40 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc
|
||||
app.telegram.verifiedTokens = app.telegram.verifiedTokens[:len(app.telegram.verifiedTokens)-1]
|
||||
}
|
||||
}
|
||||
if invite.Profile != "" && app.config.Section("ombi").Key("enabled").MustBool(false) {
|
||||
if profile.Ombi != nil && len(profile.Ombi) != 0 {
|
||||
template := profile.Ombi
|
||||
errors, code, err := app.ombi.NewUser(req.Username, req.Password, req.Email, template)
|
||||
if err != nil || code != 200 {
|
||||
app.info.Printf("Failed to create Ombi user (%d): %s", code, err)
|
||||
app.debug.Printf("Errors reported by Ombi: %s", strings.Join(errors, ", "))
|
||||
} else {
|
||||
app.info.Println("Created Ombi user")
|
||||
if (discordEnabled && discordVerified) || (telegramEnabled && telegramTokenIndex != -1) {
|
||||
ombiUser, status, err := app.getOmbiUser(id)
|
||||
if status != 200 || err != nil {
|
||||
app.err.Printf("Failed to get Ombi user (%d): %v", status, err)
|
||||
} else {
|
||||
dID := ""
|
||||
tUser := ""
|
||||
if discordEnabled && discordVerified {
|
||||
dID = discordUser.ID
|
||||
}
|
||||
if telegramEnabled && telegramTokenIndex != -1 {
|
||||
tUser = app.storage.telegram[user.ID].Username
|
||||
}
|
||||
resp, status, err := app.ombi.SetNotificationPrefs(ombiUser, dID, tUser)
|
||||
if !(status == 200 || status == 204) || err != nil {
|
||||
app.err.Printf("Failed to link Telegram/Discord to Ombi (%d): %v", status, err)
|
||||
app.debug.Printf("Response: %v", resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
app.debug.Printf("Skipping Ombi: Profile \"%s\" was empty", invite.Profile)
|
||||
}
|
||||
}
|
||||
if matrixVerified {
|
||||
matrixUser.Contact = req.MatrixContact
|
||||
delete(app.matrix.tokens, req.MatrixPIN)
|
||||
@@ -626,6 +660,11 @@ func (app *appContext) NewUser(gc *gin.Context) {
|
||||
var req newUserDTO
|
||||
gc.BindJSON(&req)
|
||||
app.debug.Printf("%s: New user attempt", req.Code)
|
||||
if app.config.Section("captcha").Key("enabled").MustBool(false) && !app.verifyCaptcha(req.Code, req.CaptchaID, req.CaptchaText) {
|
||||
app.info.Printf("%s: New user failed: Captcha Incorrect", req.Code)
|
||||
respond(400, "errorCaptcha", gc)
|
||||
return
|
||||
}
|
||||
if !app.checkInvite(req.Code, false, "") {
|
||||
app.info.Printf("%s New user failed: invalid code", req.Code)
|
||||
respond(401, "errorInvalidCode", gc)
|
||||
@@ -1451,6 +1490,8 @@ func (app *appContext) GetUsers(gc *gin.Context) {
|
||||
respond(500, "Couldn't get users", gc)
|
||||
return
|
||||
}
|
||||
adminOnly := app.config.Section("ui").Key("admin_only").MustBool(true)
|
||||
allowAll := app.config.Section("ui").Key("allow_all").MustBool(false)
|
||||
i := 0
|
||||
app.storage.usersLock.Lock()
|
||||
defer app.storage.usersLock.Unlock()
|
||||
@@ -1467,6 +1508,8 @@ func (app *appContext) GetUsers(gc *gin.Context) {
|
||||
if email, ok := app.storage.emails[jfUser.ID]; ok {
|
||||
user.Email = email.Addr
|
||||
user.NotifyThroughEmail = email.Contact
|
||||
user.Label = email.Label
|
||||
user.AccountsAdmin = (app.jellyfinLogin) && (email.Admin || (adminOnly && jfUser.Policy.IsAdministrator) || allowAll)
|
||||
}
|
||||
expiry, ok := app.storage.users[jfUser.ID]
|
||||
if ok {
|
||||
@@ -1577,6 +1620,80 @@ func (app *appContext) DeleteOmbiProfile(gc *gin.Context) {
|
||||
respondBool(204, true, gc)
|
||||
}
|
||||
|
||||
// @Summary Set whether or not a user can access jfa-go. Redundant if the user is a Jellyfin admin.
|
||||
// @Produce json
|
||||
// @Param setAccountsAdminDTO body setAccountsAdminDTO true "Map of userIDs to whether or not they have access."
|
||||
// @Success 204 {object} boolResponse
|
||||
// @Failure 500 {object} boolResponse
|
||||
// @Router /users/accounts-admin [post]
|
||||
// @Security Bearer
|
||||
// @tags Users
|
||||
func (app *appContext) SetAccountsAdmin(gc *gin.Context) {
|
||||
var req setAccountsAdminDTO
|
||||
gc.BindJSON(&req)
|
||||
app.debug.Println("Admin modification requested")
|
||||
users, status, err := app.jf.GetUsers(false)
|
||||
if !(status == 200 || status == 204) || err != nil {
|
||||
app.err.Printf("Failed to get users from Jellyfin (%d): %v", status, err)
|
||||
respond(500, "Couldn't get users", gc)
|
||||
return
|
||||
}
|
||||
for _, jfUser := range users {
|
||||
id := jfUser.ID
|
||||
if admin, ok := req[id]; ok {
|
||||
var emailStore = EmailAddress{}
|
||||
if oldEmail, ok := app.storage.emails[id]; ok {
|
||||
emailStore = oldEmail
|
||||
}
|
||||
emailStore.Admin = admin
|
||||
app.storage.emails[id] = emailStore
|
||||
}
|
||||
}
|
||||
if err := app.storage.storeEmails(); err != nil {
|
||||
app.err.Printf("Failed to store email list: %v", err)
|
||||
respondBool(500, false, gc)
|
||||
}
|
||||
app.info.Println("Email list modified")
|
||||
respondBool(204, true, gc)
|
||||
}
|
||||
|
||||
// @Summary Modify user's labels, which show next to their name in the accounts tab.
|
||||
// @Produce json
|
||||
// @Param modifyEmailsDTO body modifyEmailsDTO true "Map of userIDs to labels"
|
||||
// @Success 204 {object} boolResponse
|
||||
// @Failure 500 {object} boolResponse
|
||||
// @Router /users/labels [post]
|
||||
// @Security Bearer
|
||||
// @tags Users
|
||||
func (app *appContext) ModifyLabels(gc *gin.Context) {
|
||||
var req modifyEmailsDTO
|
||||
gc.BindJSON(&req)
|
||||
app.debug.Println("Label modification requested")
|
||||
users, status, err := app.jf.GetUsers(false)
|
||||
if !(status == 200 || status == 204) || err != nil {
|
||||
app.err.Printf("Failed to get users from Jellyfin (%d): %v", status, err)
|
||||
respond(500, "Couldn't get users", gc)
|
||||
return
|
||||
}
|
||||
for _, jfUser := range users {
|
||||
id := jfUser.ID
|
||||
if label, ok := req[id]; ok {
|
||||
var emailStore = EmailAddress{}
|
||||
if oldEmail, ok := app.storage.emails[id]; ok {
|
||||
emailStore = oldEmail
|
||||
}
|
||||
emailStore.Label = label
|
||||
app.storage.emails[id] = emailStore
|
||||
}
|
||||
}
|
||||
if err := app.storage.storeEmails(); err != nil {
|
||||
app.err.Printf("Failed to store email list: %v", err)
|
||||
respondBool(500, false, gc)
|
||||
}
|
||||
app.info.Println("Email list modified")
|
||||
respondBool(204, true, gc)
|
||||
}
|
||||
|
||||
// @Summary Modify user's email addresses.
|
||||
// @Produce json
|
||||
// @Param modifyEmailsDTO body modifyEmailsDTO true "Map of userIDs to email addresses"
|
||||
@@ -1599,11 +1716,12 @@ func (app *appContext) ModifyEmails(gc *gin.Context) {
|
||||
for _, jfUser := range users {
|
||||
id := jfUser.ID
|
||||
if address, ok := req[id]; ok {
|
||||
contact := true
|
||||
if oldAddr, ok := app.storage.emails[id]; ok {
|
||||
contact = oldAddr.Contact
|
||||
var emailStore = EmailAddress{}
|
||||
if oldEmail, ok := app.storage.emails[id]; ok {
|
||||
emailStore = oldEmail
|
||||
}
|
||||
app.storage.emails[id] = EmailAddress{Addr: address, Contact: contact}
|
||||
emailStore.Addr = address
|
||||
app.storage.emails[id] = emailStore
|
||||
if ombiEnabled {
|
||||
ombiUser, code, err := app.getOmbiUser(id)
|
||||
if code == 200 && err == nil {
|
||||
@@ -1939,6 +2057,20 @@ func (app *appContext) GetConfig(gc *gin.Context) {
|
||||
resp.Sections[sectName].Settings[settingName] = s
|
||||
}
|
||||
}
|
||||
if discordEnabled {
|
||||
r, err := app.discord.ListRoles()
|
||||
if err == nil {
|
||||
roles := make([][2]string, len(r)+1)
|
||||
roles[0] = [2]string{"", "None"}
|
||||
for i, role := range r {
|
||||
roles[i+1] = role
|
||||
}
|
||||
s := resp.Sections["discord"].Settings["apply_role"]
|
||||
s.Options = roles
|
||||
resp.Sections["discord"].Settings["apply_role"] = s
|
||||
}
|
||||
}
|
||||
|
||||
resp.Sections["ui"].Settings["language-form"] = fl
|
||||
resp.Sections["ui"].Settings["language-admin"] = al
|
||||
resp.Sections["email"].Settings["language"] = el
|
||||
@@ -1983,7 +2115,9 @@ func (app *appContext) ModifyConfig(gc *gin.Context) {
|
||||
if section == "email" && setting == "method" && value == "disabled" {
|
||||
value = ""
|
||||
}
|
||||
if value.(string) != app.config.Section(section).Key(setting).MustString("") {
|
||||
if (section == "discord" || section == "matrix") && setting == "language" {
|
||||
tempConfig.Section("telegram").Key("language").SetValue(value.(string))
|
||||
} else if value.(string) != app.config.Section(section).Key(setting).MustString("") {
|
||||
tempConfig.Section(section).Key(setting).SetValue(value.(string))
|
||||
}
|
||||
}
|
||||
@@ -2452,6 +2586,7 @@ func (app *appContext) TelegramAddUser(gc *gin.Context) {
|
||||
app.telegram.verifiedTokens[len(app.telegram.verifiedTokens)-1], app.telegram.verifiedTokens[tokenIndex] = app.telegram.verifiedTokens[tokenIndex], app.telegram.verifiedTokens[len(app.telegram.verifiedTokens)-1]
|
||||
app.telegram.verifiedTokens = app.telegram.verifiedTokens[:len(app.telegram.verifiedTokens)-1]
|
||||
}
|
||||
linkExistingOmbiDiscordTelegram(app)
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -2830,6 +2965,7 @@ func (app *appContext) DiscordConnect(gc *gin.Context) {
|
||||
respondBool(500, false, gc)
|
||||
return
|
||||
}
|
||||
linkExistingOmbiDiscordTelegram(app)
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -2845,6 +2981,15 @@ func (app *appContext) restart(gc *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// @Summary Returns the last 100 lines of the log.
|
||||
// @Router /log [get]
|
||||
// @Success 200 {object} LogDTO
|
||||
// @Security Bearer
|
||||
// @tags Other
|
||||
func (app *appContext) GetLog(gc *gin.Context) {
|
||||
gc.JSON(200, LogDTO{lineCache.String()})
|
||||
}
|
||||
|
||||
// no need to syscall.exec anymore!
|
||||
func (app *appContext) Restart() error {
|
||||
if TRAY {
|
||||
|
||||
10
auth.go
10
auth.go
@@ -145,8 +145,14 @@ func (app *appContext) getTokenLogin(gc *gin.Context) {
|
||||
return
|
||||
}
|
||||
jfID = user.ID
|
||||
if app.config.Section("ui").Key("admin_only").MustBool(true) {
|
||||
if !user.Policy.IsAdministrator {
|
||||
if !app.config.Section("ui").Key("allow_all").MustBool(false) {
|
||||
accountsAdmin := false
|
||||
adminOnly := app.config.Section("ui").Key("admin_only").MustBool(true)
|
||||
if emailStore, ok := app.storage.emails[jfID]; ok {
|
||||
accountsAdmin = emailStore.Admin
|
||||
}
|
||||
accountsAdmin = accountsAdmin || (adminOnly && user.Policy.IsAdministrator)
|
||||
if !accountsAdmin {
|
||||
app.debug.Printf("Auth denied: Users \"%s\" isn't admin", creds[0])
|
||||
respond(401, "Unauthorized", gc)
|
||||
return
|
||||
|
||||
@@ -76,6 +76,9 @@ func (app *appContext) loadConfig() error {
|
||||
app.MustSetValue("smtp", "hello_hostname", "localhost")
|
||||
app.MustSetValue("smtp", "cert_validation", "true")
|
||||
|
||||
sc := app.config.Section("discord").Key("start_command").MustString("start")
|
||||
app.config.Section("discord").Key("start_command").SetValue(strings.TrimPrefix(strings.TrimPrefix(sc, "/"), "!"))
|
||||
|
||||
jfUrl := app.config.Section("jellyfin").Key("server").String()
|
||||
if !(strings.HasPrefix(jfUrl, "http://") || strings.HasPrefix(jfUrl, "https://")) {
|
||||
app.config.Section("jellyfin").Key("server").SetValue("http://" + jfUrl)
|
||||
|
||||
@@ -181,6 +181,15 @@
|
||||
"value": true,
|
||||
"description": "Allows only admin users on Jellyfin to access the admin page."
|
||||
},
|
||||
"allow_all": {
|
||||
"name": "Allow all users to login",
|
||||
"required": false,
|
||||
"requires_restart": true,
|
||||
"depends_true": "jellyfin_login",
|
||||
"type": "bool",
|
||||
"value": false,
|
||||
"description": "Allow all Jellyfin users to access jfa-go. Not recommended, add individual users in the Accounts tab instead."
|
||||
},
|
||||
"username": {
|
||||
"name": "Web Username",
|
||||
"required": true,
|
||||
@@ -241,7 +250,7 @@
|
||||
"description": "Displayed when a user creates an account"
|
||||
},
|
||||
"url_base": {
|
||||
"name": "URL Base",
|
||||
"name": "Reverse Proxy subfolder",
|
||||
"required": false,
|
||||
"requires_restart": true,
|
||||
"type": "text",
|
||||
@@ -303,6 +312,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"captcha": {
|
||||
"order": [],
|
||||
"meta": {
|
||||
"name": "Captcha",
|
||||
"description": "Settings related to user creation CAPTCHAs."
|
||||
},
|
||||
"settings": {
|
||||
"enabled": {
|
||||
"name": "Enabled",
|
||||
"required": false,
|
||||
"requires_restart": true,
|
||||
"type": "bool",
|
||||
"value": false,
|
||||
"description": "Enable a CAPTCHA on the account creation form."
|
||||
}
|
||||
}
|
||||
},
|
||||
"password_validation": {
|
||||
"order": [],
|
||||
"meta": {
|
||||
@@ -630,7 +656,7 @@
|
||||
"requires_restart": true,
|
||||
"depends_true": "enabled",
|
||||
"type": "text",
|
||||
"value": "!start",
|
||||
"value": "start",
|
||||
"description": "Command to start the user verification process."
|
||||
},
|
||||
"channel": {
|
||||
@@ -660,6 +686,18 @@
|
||||
"value": "",
|
||||
"description": "Channel to invite new users to."
|
||||
},
|
||||
"apply_role": {
|
||||
"name": "Apply Role on connection",
|
||||
"required": false,
|
||||
"requires_restart": true,
|
||||
"depends_true": "enabled",
|
||||
"type": "select",
|
||||
"options": [
|
||||
["", "None"]
|
||||
],
|
||||
"value": "",
|
||||
"description": "Add the selected role to a user when they sign up."
|
||||
},
|
||||
"language": {
|
||||
"name": "Language",
|
||||
"required": false,
|
||||
|
||||
40
css/base.css
40
css/base.css
@@ -1,13 +1,13 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@import "remixicon.css";
|
||||
@import "./modal.css";
|
||||
@import "./dark.css";
|
||||
@import "./tooltip.css";
|
||||
@import "./loader.css";
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
:root {
|
||||
--border-width-default: 2px;
|
||||
--border-width-2: 3px;
|
||||
@@ -88,11 +88,6 @@ html:not(.dark) .card.\@low:not(.\~neutral):not(.\~positive):not(.\~urge):not(.\
|
||||
padding: var(--spacing-4,1rem);
|
||||
}
|
||||
|
||||
.modal-content .banner {
|
||||
margin-left: calc(-1 * var(--spacing-4,1rem) - 0.5%); /* Not sure why this is necessary */
|
||||
margin-right: calc(-1 * var(--spacing-4,1rem) - 0.5%);
|
||||
}
|
||||
|
||||
div.card:contains(section.banner.footer) {
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
@@ -129,20 +124,11 @@ div.card:contains(section.banner.footer) {
|
||||
align-items: top;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-expand {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.flex-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.flex-row-group {
|
||||
display: block;
|
||||
flex-grow: 1;
|
||||
@@ -177,6 +163,18 @@ span.sm:not(.heading) {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.flex-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
.flex-form {
|
||||
flex: 1;
|
||||
margin: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 400px) {
|
||||
.row {
|
||||
flex-direction: column;
|
||||
@@ -304,7 +302,7 @@ sup.\~critical, .text-critical {
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.block {
|
||||
.block {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -540,3 +538,7 @@ div.card:contains(section.banner.footer) {
|
||||
.text-center-i {
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
input[type="checkbox" i], [class^="ri-"], [class*=" ri-"], .ri-refresh-line:before, .modal-close {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -10,56 +10,6 @@
|
||||
background-color: rgba(0,0,0,40%);
|
||||
}
|
||||
|
||||
.modal-shown {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@keyframes modal-hide {
|
||||
from { opacity: 1; }
|
||||
to { opacity: 0; }
|
||||
}
|
||||
|
||||
.modal-hiding {
|
||||
animation: modal-hide 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
||||
}
|
||||
|
||||
@keyframes modal-content-show {
|
||||
from {
|
||||
opacity: 0;
|
||||
top: -6rem;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
position: relative;
|
||||
margin: 10% auto;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.modal-content.wide {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.modal-shown .modal-content {
|
||||
animation: modal-content-show 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1000px) {
|
||||
.modal-content.wide {
|
||||
width: 75%;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 400px) {
|
||||
.modal-content, .modal-content.wide {
|
||||
width: 90%;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
float: right;
|
||||
color: #aaa;
|
||||
|
||||
276
discord.go
276
discord.go
@@ -18,7 +18,10 @@ type DiscordDaemon struct {
|
||||
guildID string
|
||||
serverChannelName, serverName string
|
||||
users map[string]DiscordUser // Map of user IDs to users. Added to on first interaction, and loaded from app.storage.discord on start.
|
||||
roleID string
|
||||
app *appContext
|
||||
commandHandlers map[string]func(s *dg.Session, i *dg.InteractionCreate, lang string)
|
||||
commandIDs []string
|
||||
}
|
||||
|
||||
func newDiscordDaemon(app *appContext) (*DiscordDaemon, error) {
|
||||
@@ -38,7 +41,13 @@ func newDiscordDaemon(app *appContext) (*DiscordDaemon, error) {
|
||||
verifiedTokens: map[string]DiscordUser{},
|
||||
users: map[string]DiscordUser{},
|
||||
app: app,
|
||||
roleID: app.config.Section("discord").Key("apply_role").String(),
|
||||
commandHandlers: map[string]func(s *dg.Session, i *dg.InteractionCreate, lang string){},
|
||||
commandIDs: []string{},
|
||||
}
|
||||
dd.commandHandlers[app.config.Section("discord").Key("start_command").MustString("start")] = dd.cmdStart
|
||||
dd.commandHandlers["lang"] = dd.cmdLang
|
||||
dd.commandHandlers["pin"] = dd.cmdPIN
|
||||
for _, user := range app.storage.discord {
|
||||
dd.users[user.ID] = user
|
||||
}
|
||||
@@ -72,6 +81,9 @@ func (d *DiscordDaemon) MustGetUser(channelID, userID, discrim, username string)
|
||||
|
||||
func (d *DiscordDaemon) run() {
|
||||
d.bot.AddHandler(d.messageHandler)
|
||||
|
||||
d.bot.AddHandler(d.commandHandler)
|
||||
|
||||
d.bot.Identify.Intents = dg.IntentsGuildMessages | dg.IntentsDirectMessages | dg.IntentsGuildMembers | dg.IntentsGuildInvites
|
||||
if err := d.bot.Open(); err != nil {
|
||||
d.app.err.Printf("Discord: Failed to start daemon: %v", err)
|
||||
@@ -105,12 +117,44 @@ func (d *DiscordDaemon) run() {
|
||||
d.inviteChannelName = invChannel
|
||||
}
|
||||
}
|
||||
defer d.deregisterCommands()
|
||||
defer d.bot.Close()
|
||||
|
||||
d.registerCommands()
|
||||
|
||||
<-d.ShutdownChannel
|
||||
d.ShutdownChannel <- "Down"
|
||||
return
|
||||
}
|
||||
|
||||
// ListRoles returns a list of available (excluding bot and @everyone) roles in a guild as a list of containing an array of the guild ID and its name.
|
||||
func (d *DiscordDaemon) ListRoles() (roles [][2]string, err error) {
|
||||
var r []*dg.Role
|
||||
r, err = d.bot.GuildRoles(d.guildID)
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Failed to get roles: %v", err)
|
||||
return
|
||||
}
|
||||
for _, role := range r {
|
||||
if role.Name != d.username && role.Name != "@everyone" {
|
||||
roles = append(roles, [2]string{role.ID, role.Name})
|
||||
}
|
||||
}
|
||||
// roles = make([][2]string, len(r))
|
||||
// for i, role := range r {
|
||||
// roles[i] = [2]string{role.ID, role.Name}
|
||||
// }
|
||||
return
|
||||
}
|
||||
|
||||
// ApplyRole applies the member role to the given user if set.
|
||||
func (d *DiscordDaemon) ApplyRole(userID string) error {
|
||||
if d.roleID == "" {
|
||||
return nil
|
||||
}
|
||||
return d.bot.GuildMemberRoleAdd(d.guildID, userID, d.roleID)
|
||||
}
|
||||
|
||||
// NewTempInvite creates an invite link, and returns the invite URL, as well as the URL for the server icon.
|
||||
func (d *DiscordDaemon) NewTempInvite(ageSeconds, maxUses int) (inviteURL, iconURL string) {
|
||||
var inv *dg.Invite
|
||||
@@ -224,6 +268,208 @@ func (d *DiscordDaemon) Shutdown() {
|
||||
close(d.ShutdownChannel)
|
||||
}
|
||||
|
||||
func (d *DiscordDaemon) registerCommands() {
|
||||
commands := []*dg.ApplicationCommand{
|
||||
{
|
||||
Name: d.app.config.Section("discord").Key("start_command").MustString("start"),
|
||||
Description: "Start the Discord linking process. The bot will send further instructions.",
|
||||
},
|
||||
{
|
||||
Name: "lang",
|
||||
Description: "Set the language for the bot.",
|
||||
Options: []*dg.ApplicationCommandOption{
|
||||
{
|
||||
Type: dg.ApplicationCommandOptionString,
|
||||
Name: "language",
|
||||
Description: "Language Name",
|
||||
Required: true,
|
||||
Choices: []*dg.ApplicationCommandOptionChoice{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "pin",
|
||||
Description: "Send PIN for Discord verification.",
|
||||
Options: []*dg.ApplicationCommandOption{
|
||||
{
|
||||
Type: dg.ApplicationCommandOptionString,
|
||||
Name: "pin",
|
||||
Description: "Verification PIN (e.g AB-CD-EF)",
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
commands[1].Options[0].Choices = make([]*dg.ApplicationCommandOptionChoice, len(d.app.storage.lang.Telegram))
|
||||
i := 0
|
||||
for code := range d.app.storage.lang.Telegram {
|
||||
commands[1].Options[0].Choices[i] = &dg.ApplicationCommandOptionChoice{
|
||||
Name: d.app.storage.lang.Telegram[code].Meta.Name,
|
||||
Value: code,
|
||||
}
|
||||
i++
|
||||
}
|
||||
|
||||
// d.deregisterCommands()
|
||||
|
||||
d.commandIDs = make([]string, len(commands))
|
||||
// cCommands, err := d.bot.ApplicationCommandBulkOverwrite(d.bot.State.User.ID, d.guildID, commands)
|
||||
// if err != nil {
|
||||
// d.app.err.Printf("Discord: Cannot create commands: %v", err)
|
||||
// }
|
||||
for i, cmd := range commands {
|
||||
command, err := d.bot.ApplicationCommandCreate(d.bot.State.User.ID, d.guildID, cmd)
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Cannot create command \"%s\": %v", cmd.Name, err)
|
||||
} else {
|
||||
d.app.debug.Printf("Discord: registered command \"%s\"", cmd.Name)
|
||||
d.commandIDs[i] = command.ID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DiscordDaemon) deregisterCommands() {
|
||||
existingCommands, err := d.bot.ApplicationCommands(d.bot.State.User.ID, d.guildID)
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Failed to get commands: %v", err)
|
||||
return
|
||||
}
|
||||
for _, cmd := range existingCommands {
|
||||
if err := d.bot.ApplicationCommandDelete(d.bot.State.User.ID, "", cmd.ID); err != nil {
|
||||
d.app.err.Printf("Failed to deregister command: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DiscordDaemon) commandHandler(s *dg.Session, i *dg.InteractionCreate) {
|
||||
if h, ok := d.commandHandlers[i.ApplicationCommandData().Name]; ok {
|
||||
if i.GuildID != "" && d.channelName != "" {
|
||||
if d.channelID == "" {
|
||||
channel, err := s.Channel(i.ChannelID)
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Couldn't get channel, will monitor all: %v", err)
|
||||
d.channelName = ""
|
||||
}
|
||||
if channel.Name == d.channelName {
|
||||
d.channelID = channel.ID
|
||||
}
|
||||
}
|
||||
if d.channelID != i.ChannelID {
|
||||
d.app.debug.Printf("Discord: Ignoring message as not in specified channel")
|
||||
return
|
||||
}
|
||||
}
|
||||
if i.Interaction.Member.User.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
lang := d.app.storage.lang.chosenTelegramLang
|
||||
if user, ok := d.users[i.Interaction.Member.User.ID]; ok {
|
||||
if _, ok := d.app.storage.lang.Telegram[user.Lang]; ok {
|
||||
lang = user.Lang
|
||||
}
|
||||
}
|
||||
h(s, i, lang)
|
||||
}
|
||||
}
|
||||
|
||||
// cmd* methods handle slash-commands, msg* methods handle ! commands.
|
||||
|
||||
func (d *DiscordDaemon) cmdStart(s *dg.Session, i *dg.InteractionCreate, lang string) {
|
||||
channel, err := s.UserChannelCreate(i.Interaction.Member.User.ID)
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Failed to create private channel with \"%s\": %v", i.Interaction.Member.User.Username, err)
|
||||
return
|
||||
}
|
||||
user := d.MustGetUser(channel.ID, i.Interaction.Member.User.ID, i.Interaction.Member.User.Discriminator, i.Interaction.Member.User.Username)
|
||||
d.users[i.Interaction.Member.User.ID] = user
|
||||
|
||||
content := d.app.storage.lang.Telegram[lang].Strings.get("discordStartMessage") + "\n"
|
||||
content += d.app.storage.lang.Telegram[lang].Strings.template("languageMessageDiscord", tmpl{"command": "/lang"})
|
||||
err = s.InteractionRespond(i.Interaction, &dg.InteractionResponse{
|
||||
// Type: dg.InteractionResponseChannelMessageWithSource,
|
||||
Type: dg.InteractionResponseChannelMessageWithSource,
|
||||
Data: &dg.InteractionResponseData{
|
||||
Content: content,
|
||||
Flags: 64, // Ephemeral
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Failed to send reply: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DiscordDaemon) cmdPIN(s *dg.Session, i *dg.InteractionCreate, lang string) {
|
||||
pin := i.ApplicationCommandData().Options[0].StringValue()
|
||||
tokenIndex := -1
|
||||
for i, token := range d.tokens {
|
||||
if pin == token {
|
||||
tokenIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if tokenIndex == -1 {
|
||||
err := s.InteractionRespond(i.Interaction, &dg.InteractionResponse{
|
||||
// Type: dg.InteractionResponseChannelMessageWithSource,
|
||||
Type: dg.InteractionResponseChannelMessageWithSource,
|
||||
Data: &dg.InteractionResponseData{
|
||||
Content: d.app.storage.lang.Telegram[lang].Strings.get("invalidPIN"),
|
||||
Flags: 64, // Ephemeral
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Failed to send message to \"%s\": %v", i.Interaction.Member.User.Username, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
err := s.InteractionRespond(i.Interaction, &dg.InteractionResponse{
|
||||
// Type: dg.InteractionResponseChannelMessageWithSource,
|
||||
Type: dg.InteractionResponseChannelMessageWithSource,
|
||||
Data: &dg.InteractionResponseData{
|
||||
Content: d.app.storage.lang.Telegram[lang].Strings.get("pinSuccess"),
|
||||
Flags: 64, // Ephemeral
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Failed to send message to \"%s\": %v", i.Interaction.Member.User.Username, err)
|
||||
}
|
||||
d.verifiedTokens[pin] = d.users[i.Interaction.Member.User.ID]
|
||||
d.tokens[len(d.tokens)-1], d.tokens[tokenIndex] = d.tokens[tokenIndex], d.tokens[len(d.tokens)-1]
|
||||
d.tokens = d.tokens[:len(d.tokens)-1]
|
||||
}
|
||||
|
||||
func (d *DiscordDaemon) cmdLang(s *dg.Session, i *dg.InteractionCreate, lang string) {
|
||||
code := i.ApplicationCommandData().Options[0].StringValue()
|
||||
if _, ok := d.app.storage.lang.Telegram[code]; ok {
|
||||
var user DiscordUser
|
||||
for jfID, u := range d.app.storage.discord {
|
||||
if u.ID == i.Interaction.Member.User.ID {
|
||||
u.Lang = code
|
||||
lang = code
|
||||
d.app.storage.discord[jfID] = u
|
||||
if err := d.app.storage.storeDiscordUsers(); err != nil {
|
||||
d.app.err.Printf("Failed to store Discord users: %v", err)
|
||||
}
|
||||
user = u
|
||||
break
|
||||
}
|
||||
}
|
||||
d.users[i.Interaction.Member.User.ID] = user
|
||||
err := s.InteractionRespond(i.Interaction, &dg.InteractionResponse{
|
||||
// Type: dg.InteractionResponseChannelMessageWithSource,
|
||||
Type: dg.InteractionResponseChannelMessageWithSource,
|
||||
Data: &dg.InteractionResponseData{
|
||||
Content: d.app.storage.lang.Telegram[lang].Strings.template("languageSet", tmpl{"language": d.app.storage.lang.Telegram[lang].Meta.Name}),
|
||||
Flags: 64, // Ephemeral
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Failed to send reply: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DiscordDaemon) messageHandler(s *dg.Session, m *dg.MessageCreate) {
|
||||
if m.GuildID != "" && d.channelName != "" {
|
||||
if d.channelID == "" {
|
||||
@@ -255,16 +501,16 @@ func (d *DiscordDaemon) messageHandler(s *dg.Session, m *dg.MessageCreate) {
|
||||
}
|
||||
}
|
||||
switch msg := sects[0]; msg {
|
||||
case d.app.config.Section("discord").Key("start_command").MustString("!start"):
|
||||
d.commandStart(s, m, lang)
|
||||
case "!" + d.app.config.Section("discord").Key("start_command").MustString("start"):
|
||||
d.msgStart(s, m, lang)
|
||||
case "!lang":
|
||||
d.commandLang(s, m, sects, lang)
|
||||
d.msgLang(s, m, sects, lang)
|
||||
default:
|
||||
d.commandPIN(s, m, sects, lang)
|
||||
d.msgPIN(s, m, sects, lang)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DiscordDaemon) commandStart(s *dg.Session, m *dg.MessageCreate, lang string) {
|
||||
func (d *DiscordDaemon) msgStart(s *dg.Session, m *dg.MessageCreate, lang string) {
|
||||
channel, err := s.UserChannelCreate(m.Author.ID)
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Failed to create private channel with \"%s\": %v", m.Author.Username, err)
|
||||
@@ -272,6 +518,13 @@ func (d *DiscordDaemon) commandStart(s *dg.Session, m *dg.MessageCreate, lang st
|
||||
}
|
||||
user := d.MustGetUser(channel.ID, m.Author.ID, m.Author.Discriminator, m.Author.Username)
|
||||
d.users[m.Author.ID] = user
|
||||
|
||||
_, err = d.bot.ChannelMessageSendReply(m.ChannelID, d.app.storage.lang.Telegram[lang].Strings.get("discordDMs"), m.Reference())
|
||||
if err != nil {
|
||||
d.app.err.Printf("Discord: Failed to send reply to \"%s\": %v", m.Author.Username, err)
|
||||
return
|
||||
}
|
||||
|
||||
content := d.app.storage.lang.Telegram[lang].Strings.get("startMessage") + "\n"
|
||||
content += d.app.storage.lang.Telegram[lang].Strings.template("languageMessage", tmpl{"command": "!lang"})
|
||||
_, err = s.ChannelMessageSend(channel.ID, content)
|
||||
@@ -281,7 +534,7 @@ func (d *DiscordDaemon) commandStart(s *dg.Session, m *dg.MessageCreate, lang st
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DiscordDaemon) commandLang(s *dg.Session, m *dg.MessageCreate, sects []string, lang string) {
|
||||
func (d *DiscordDaemon) msgLang(s *dg.Session, m *dg.MessageCreate, sects []string, lang string) {
|
||||
if len(sects) == 1 {
|
||||
list := "!lang <lang>\n"
|
||||
for code := range d.app.storage.lang.Telegram {
|
||||
@@ -299,13 +552,14 @@ func (d *DiscordDaemon) commandLang(s *dg.Session, m *dg.MessageCreate, sects []
|
||||
}
|
||||
if _, ok := d.app.storage.lang.Telegram[sects[1]]; ok {
|
||||
var user DiscordUser
|
||||
for jfID, user := range d.app.storage.discord {
|
||||
if user.ID == m.Author.ID {
|
||||
user.Lang = sects[1]
|
||||
d.app.storage.discord[jfID] = user
|
||||
for jfID, u := range d.app.storage.discord {
|
||||
if u.ID == m.Author.ID {
|
||||
u.Lang = sects[1]
|
||||
d.app.storage.discord[jfID] = u
|
||||
if err := d.app.storage.storeDiscordUsers(); err != nil {
|
||||
d.app.err.Printf("Failed to store Discord users: %v", err)
|
||||
}
|
||||
user = u
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -313,7 +567,7 @@ func (d *DiscordDaemon) commandLang(s *dg.Session, m *dg.MessageCreate, sects []
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DiscordDaemon) commandPIN(s *dg.Session, m *dg.MessageCreate, sects []string, lang string) {
|
||||
func (d *DiscordDaemon) msgPIN(s *dg.Session, m *dg.MessageCreate, sects []string, lang string) {
|
||||
if _, ok := d.users[m.Author.ID]; ok {
|
||||
channel, err := s.Channel(m.ChannelID)
|
||||
if err != nil {
|
||||
|
||||
3
email.go
3
email.go
@@ -191,6 +191,8 @@ func (emailer *Emailer) NewMailgun(url, key string) {
|
||||
// Mailgun client takes the base url, so we need to trim off the end (e.g 'v3/messages')
|
||||
if strings.Contains(url, "messages") {
|
||||
url = url[0:strings.LastIndex(url, "/")]
|
||||
}
|
||||
if strings.Contains(url, "v3") {
|
||||
url = url[0:strings.LastIndex(url, "/")]
|
||||
}
|
||||
sender.client.SetAPIBase(url)
|
||||
@@ -612,7 +614,6 @@ func (emailer *Emailer) deletedValues(reason string, app *appContext, noSub bool
|
||||
template["reason"] = reason
|
||||
template["message"] = app.config.Section("messages").Key("message").String()
|
||||
}
|
||||
fmt.Println("TTTT", template)
|
||||
return template
|
||||
}
|
||||
|
||||
|
||||
12
go.mod
12
go.mod
@@ -13,7 +13,7 @@ replace github.com/hrfee/jfa-go/logger => ./logger
|
||||
replace github.com/hrfee/jfa-go/linecache => ./linecache
|
||||
|
||||
require (
|
||||
github.com/bwmarrin/discordgo v0.23.2
|
||||
github.com/bwmarrin/discordgo v0.23.3-0.20211228023845-29269347e820
|
||||
github.com/emersion/go-autostart v0.0.0-20210130080809-00ed301c8e9a
|
||||
github.com/fatih/color v1.13.0
|
||||
github.com/fsnotify/fsnotify v1.5.1
|
||||
@@ -24,7 +24,6 @@ require (
|
||||
github.com/gin-contrib/pprof v1.3.0
|
||||
github.com/gin-contrib/static v0.0.1
|
||||
github.com/gin-gonic/gin v1.7.7
|
||||
github.com/go-openapi/spec v0.20.4 // indirect
|
||||
github.com/go-playground/validator/v10 v10.9.0 // indirect
|
||||
github.com/go-stack/stack v1.8.1 // indirect
|
||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
|
||||
@@ -47,17 +46,18 @@ require (
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
|
||||
github.com/steambap/captcha v1.4.1
|
||||
github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2
|
||||
github.com/swaggo/gin-swagger v1.3.3
|
||||
github.com/swaggo/swag v1.7.6 // indirect
|
||||
github.com/swaggo/swag v1.7.8 // indirect
|
||||
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
|
||||
github.com/tidwall/sjson v1.2.4 // indirect
|
||||
github.com/ugorji/go v1.2.6 // indirect
|
||||
github.com/writeas/go-strip-markdown v2.0.1+incompatible
|
||||
github.com/xhit/go-simple-mail/v2 v2.10.0
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
|
||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
||||
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect
|
||||
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba // indirect
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
|
||||
golang.org/x/tools v0.1.8 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gopkg.in/ini.v1 v1.66.2
|
||||
|
||||
35
go.sum
35
go.sum
@@ -20,8 +20,8 @@ github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVa
|
||||
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
|
||||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
|
||||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/bwmarrin/discordgo v0.23.2 h1:BzrtTktixGHIu9Tt7dEE6diysEF9HWnXeHuoJEt2fH4=
|
||||
github.com/bwmarrin/discordgo v0.23.2/go.mod h1:c1WtWUGN6nREDmzIpyTp/iD3VYt4Fpx+bVyfBG7JE+M=
|
||||
github.com/bwmarrin/discordgo v0.23.3-0.20211228023845-29269347e820 h1:MIW5DnBVJAgAy4LYBqWwIMBB0ezklvh8b7DsYvHZHb0=
|
||||
github.com/bwmarrin/discordgo v0.23.3-0.20211228023845-29269347e820/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
@@ -124,6 +124,8 @@ github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf
|
||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
@@ -141,12 +143,9 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/hrfee/mediabrowser v0.3.7 h1:F57Cmwst4fOfhPuOlanKiOuek9zCVcXm78/zP/1WB2s=
|
||||
github.com/hrfee/mediabrowser v0.3.7/go.mod h1:PnHZbdxmbv1wCVdAQyM7nwPwpVj9fdKx2EcET7sAk+U=
|
||||
github.com/hrfee/mediabrowser v0.3.8 h1:y0iBCb6jE3QKcsiCJSYva2fFPHRn4UA+sGRzoPuJ/Dk=
|
||||
github.com/hrfee/mediabrowser v0.3.8/go.mod h1:PnHZbdxmbv1wCVdAQyM7nwPwpVj9fdKx2EcET7sAk+U=
|
||||
github.com/itchyny/timefmt-go v0.1.3 h1:7M3LGVDsqcd0VZH2U+x393obrzZisp7C0uEe921iRkU=
|
||||
@@ -237,6 +236,8 @@ github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EE
|
||||
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/steambap/captcha v1.4.1 h1:OmMdxLCWCqJvsFaFYwRpvMckIuvI6s8s1LsBrBw97P0=
|
||||
github.com/steambap/captcha v1.4.1/go.mod h1:oC9T7IfEgnrhzjDz5Djf1H7GPffCzRMbsQfFkJmhlnk=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
@@ -254,8 +255,8 @@ github.com/swaggo/gin-swagger v1.3.3/go.mod h1:ymsZuGpbbu+S7ZoQ49QPpZoDBj6uqhb8W
|
||||
github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y=
|
||||
github.com/swaggo/swag v1.6.7/go.mod h1:xDhTyuFIujYiN3DKWC/H/83xcfHp+UE/IzWWampG7Zc=
|
||||
github.com/swaggo/swag v1.7.4/go.mod h1:zD8h6h4SPv7t3l+4BKdRquqW1ASWjKZgT6Qv9z3kNqI=
|
||||
github.com/swaggo/swag v1.7.6 h1:UbAqHyXkW2J+cDjs5S43MkuYR7a6stB7Am7SK8NBmRg=
|
||||
github.com/swaggo/swag v1.7.6/go.mod h1:7vLqNYEtYoIsD14wXgy9oDS65MNiDANrPtbk9rnLuj0=
|
||||
github.com/swaggo/swag v1.7.8 h1:w249t0l/kc/DKMGlS0fppNJQxKyJ8heNaUWB6nsH3zc=
|
||||
github.com/swaggo/swag v1.7.8/go.mod h1:gZ+TJ2w/Ve1RwQsA2IRoSOTidHz6DX+PIG8GWvbnoLU=
|
||||
github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
|
||||
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
|
||||
github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
@@ -288,19 +289,23 @@ github.com/writeas/go-strip-markdown v2.0.1+incompatible/go.mod h1:Rsyu10ZhbEK9p
|
||||
github.com/xhit/go-simple-mail/v2 v2.10.0 h1:nib6RaJ4qVh5HD9UE9QJqnUZyWp3upv+Z6CFxaMj0V8=
|
||||
github.com/xhit/go-simple-mail/v2 v2.10.0/go.mod h1:kA1XbQfCI4JxQ9ccSN6VFyIEkkugOm7YiPkA5hKiQn4=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI=
|
||||
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -321,8 +326,8 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=
|
||||
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba h1:6u6sik+bn/y7vILcYkK3iwTBWN7WtBvB0+SZswQnbf8=
|
||||
golang.org/x/net v0.0.0-20220121210141-e204ce36a2ba/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -347,11 +352,14 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@@ -366,6 +374,7 @@ golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgw
|
||||
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
||||
golang.org/x/tools v0.1.8 h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w=
|
||||
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="{{ .cssClass }}">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="css/bundle.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/{{ .cssVersion }}bundle.css">
|
||||
{{ template "header.html" . }}
|
||||
<title>404 - jfa-go</title>
|
||||
</head>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="{{ .cssClass }}">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="{{ .urlBase }}/css/bundle.css">
|
||||
<link rel="stylesheet" type="text/css" href="{{ .urlBase }}/css/{{ .cssVersion }}bundle.css">
|
||||
<script>
|
||||
window.URLBase = "{{ .urlBase }}";
|
||||
window.notificationsEnabled = {{ .notifications }};
|
||||
@@ -14,13 +14,16 @@
|
||||
window.langFile = JSON.parse({{ .language }});
|
||||
window.linkResetEnabled = {{ .linkResetEnabled }};
|
||||
window.language = "{{ .langName }}";
|
||||
window.jellyfinLogin = {{ .jellyfinLogin }};
|
||||
window.jfAdminOnly = {{ .jfAdminOnly }};
|
||||
window.jfAllowAll = {{ .jfAllowAll }};
|
||||
</script>
|
||||
{{ template "header.html" . }}
|
||||
<title>Admin - jfa-go</title>
|
||||
{{ template "header.html" . }}
|
||||
</head>
|
||||
<body class="max-w-full overflow-x-hidden section">
|
||||
<div id="modal-login" class="modal">
|
||||
<form class="modal-content card" id="form-login" href="">
|
||||
<form class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3" id="form-login" href="">
|
||||
<span class="heading">{{ .strings.login }}</span>
|
||||
<input type="text" class="field input ~neutral @high mt-4 mb-2" placeholder="{{ .strings.username }}" id="login-user">
|
||||
<input type="password" class="field input ~neutral @high mb-4" placeholder="{{ .strings.password }}" id="login-password">
|
||||
@@ -31,7 +34,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-add-user" class="modal">
|
||||
<form class="modal-content card" id="form-add-user" href="">
|
||||
<form class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3" id="form-add-user" href="">
|
||||
<span class="heading">{{ .strings.newUser }} <span class="modal-close">×</span></span>
|
||||
<input type="text" class="field input ~neutral @high mt-4 mb-2" placeholder="{{ .strings.username }}" id="add-user-user">
|
||||
<input type="email" class="field input ~neutral @high mt-4 mb-2" placeholder="{{ .strings.emailAddress }}">
|
||||
@@ -43,11 +46,11 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-about" class="modal">
|
||||
<div class="modal-content content card">
|
||||
<div class="relative mx-auto my-[10%] w-4/5 lg:w-1/3 content card">
|
||||
<img src="{{ .urlBase }}/banner.svg" class="banner header" alt="jfa-go banner">
|
||||
<span class="heading"><span class="modal-close">×</span></span>
|
||||
<p>{{ .strings.version }} <span class="code font-mono bg-inherit">{{ .version }}</span></p>
|
||||
<p>{{ .strings.commitNoun }} <span class="code font-mono bg-inherit">{{ .commit }}</span></p>
|
||||
<p>{{ .strings.version }} <span class="text-black dark:text-white font-mono bg-inherit">{{ .version }}</span></p>
|
||||
<p>{{ .strings.commitNoun }} <span class="text-black dark:text-white font-mono bg-inherit">{{ .commit }}</span></p>
|
||||
<div class="row col flex">
|
||||
<a class="button ~neutral mr-2 mt-4 mb-4 lang-link" href="https://github.com/hrfee/jfa-go"><i class="ri-github-line mr-2"></i>github</a>
|
||||
<a class="button ~urge mt-4 mb-4 mr-2 lang-link" href="https://wiki.jfa-go.com">wiki/docs</a>
|
||||
@@ -71,8 +74,14 @@
|
||||
<pre class="font-mono bg-inherit">{{ .license }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div id="modal-logs" class="modal">
|
||||
<div class="relative mx-auto my-[10%] w-4/5 lg:w-2/3 content content card">
|
||||
<span class="heading">{{ .strings.logs }}<span class="modal-close">×</span></span>
|
||||
<pre class="monospace" id="log-area"></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div id="modal-modify-user" class="modal">
|
||||
<form class="modal-content card" id="form-modify-user" href="">
|
||||
<form class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3" id="form-modify-user" href="">
|
||||
<span class="heading"><span id="header-modify-user"></span> <span class="modal-close">×</span></span>
|
||||
<p class="content my-4">{{ .strings.modifySettingsDescription }}</p>
|
||||
<div class="flex-row mb-4">
|
||||
@@ -102,7 +111,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-delete-user" class="modal">
|
||||
<form class="modal-content card" id="form-delete-user" href="">
|
||||
<form class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3" id="form-delete-user" href="">
|
||||
<span class="heading"><span id="header-delete-user"></span> <span class="modal-close">×</span></span>
|
||||
<div class="content mt-8">
|
||||
<label class="switch mb-4">
|
||||
@@ -118,7 +127,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-extend-expiry" class="modal">
|
||||
<form class="modal-content card" id="form-extend-expiry" href="">
|
||||
<form class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3" id="form-extend-expiry" href="">
|
||||
<span class="heading"><span id="header-extend-expiry"></span> <span class="modal-close">×</span></span>
|
||||
<div class="content mt-8">
|
||||
<div class="row">
|
||||
@@ -170,7 +179,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-announce" class="modal">
|
||||
<form class="modal-content wide card" id="form-announce" href="">
|
||||
<form class="relative mx-auto my-[10%] w-4/5 lg:w-2/3 content card" id="form-announce" href="">
|
||||
<span class="heading"><span id="header-announce"></span> <span class="modal-close">×</span></span>
|
||||
<div class="row">
|
||||
<div class="col card ~neutral @low">
|
||||
@@ -205,7 +214,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-customize" class="modal">
|
||||
<div class="modal-content card">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3">
|
||||
<span class="heading">{{ .strings.customizeMessages }} <span class="modal-close">×</span></span>
|
||||
<p class="content my-4">{{ .strings.customizeMessagesDescription }}</p>
|
||||
<div class="table-responsive">
|
||||
@@ -223,7 +232,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="modal-editor" class="modal">
|
||||
<form class="modal-content wide card" id="form-editor" href="">
|
||||
<form class="relative mx-auto my-[10%] w-4/5 lg:w-2/3 content card" id="form-editor" href="">
|
||||
<span class="heading"><span id="header-editor"></span> <span class="modal-close">×</span></span>
|
||||
<div class="row">
|
||||
<div class="col card ~neutral @low">
|
||||
@@ -249,7 +258,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-restart" class="modal">
|
||||
<div class="modal-content card ~critical @low">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3 ~critical @low">
|
||||
<span class="heading">{{ .strings.settingsRestartRequired }} <span class="modal-close">×</span></span>
|
||||
<p class="content my-4">{{ .strings.settingsRestartRequiredDescription }}</p>
|
||||
<div class="float-right">
|
||||
@@ -259,20 +268,20 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="modal-refresh" class="modal">
|
||||
<div class="modal-content card ~neutral @low">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3 ~neutral @low">
|
||||
<span class="heading">{{ .strings.settingsApplied }}</span>
|
||||
<p class="content">{{ .strings.settingsRefreshPage }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="modal-send-pwr" class="modal">
|
||||
<div class="modal-content card ~neutral @low">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3 ~neutral @low">
|
||||
<span class="heading">{{ .strings.sendPWR }}</span>
|
||||
<p class="content my-2" id="send-pwr-note"></p>
|
||||
<span class="button ~urge @low mt-2" id="send-pwr-link">{{ .strings.copy }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="modal-ombi-profile" class="modal">
|
||||
<form class="modal-content card" id="form-ombi-defaults" href="">
|
||||
<form class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3" id="form-ombi-defaults" href="">
|
||||
<span class="heading">{{ .strings.ombiProfile }} <span class="modal-close">×</span></span>
|
||||
<p class="content my-4">{{ .strings.ombiUserDefaultsDescription }}</p>
|
||||
<div class="select ~neutral @low mb-4">
|
||||
@@ -285,7 +294,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-user-profiles" class="modal">
|
||||
<div class="modal-content wide card">
|
||||
<div class="relative mx-auto my-[10%] w-4/5 lg:w-2/3 content card">
|
||||
<span class="heading">{{ .strings.userProfiles }} <span class="modal-close">×</span></span>
|
||||
<p class="content my-4">{{ .strings.userProfilesDescription }}</p>
|
||||
<div class="table-responsive">
|
||||
@@ -308,7 +317,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="modal-add-profile" class="modal">
|
||||
<form class="modal-content card" id="form-add-profile" href="">
|
||||
<form class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3" id="form-add-profile" href="">
|
||||
<span class="heading">{{ .strings.addProfile }} <span class="modal-close">×</span></span>
|
||||
<p class="content my-4">{{ .strings.addProfileDescription }}</p>
|
||||
<label>
|
||||
@@ -331,23 +340,23 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="modal-update" class="modal">
|
||||
<div class="modal-content wide card">
|
||||
<div class="relative mx-auto my-[10%] w-4/5 lg:w-2/3 content card">
|
||||
<span class="heading">{{ .strings.updates }} <span class="modal-close">×</span></span>
|
||||
<p class="content">
|
||||
<h2>
|
||||
<h2 class="mt-2">
|
||||
<a id="update-version"></a> (<span class="font-mono bg-inherit" id="update-commit"></span>)
|
||||
</h2>
|
||||
<p class="content" id="update-description"></p>
|
||||
<p class="support" id="update-date"></p>
|
||||
<div class="content markdown-box" id="update-changelog"></div>
|
||||
<p class="content mt-2" id="update-description"></p>
|
||||
<p class="support mt-2" id="update-date"></p>
|
||||
<div class="content markdown-box mt-2" id="update-changelog"></div>
|
||||
</p>
|
||||
<span class="button ~info @low full-width center" id="update-download">{{ .strings.download }}</span>
|
||||
<span class="button ~urge @low full-width center" id="update-update">{{ .strings.update }}</span>
|
||||
<span class="button ~info @low full-width center mt-2" id="update-download">{{ .strings.download }}</span>
|
||||
<span class="button ~urge @low full-width center mt-2" id="update-update">{{ .strings.update }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{{ if .telegramEnabled }}
|
||||
<div id="modal-telegram" class="modal">
|
||||
<div class="modal-content card">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3">
|
||||
<span class="heading mb-4">{{ .strings.linkTelegram }}</span>
|
||||
<p class="content mb-4">{{ .strings.sendPIN }}</p>
|
||||
<h1 class="ac" id="telegram-pin"></h1>
|
||||
@@ -365,7 +374,7 @@
|
||||
{{ end }}
|
||||
{{ if .discordEnabled }}
|
||||
<div id="modal-discord" class="modal">
|
||||
<div class="modal-content card">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3">
|
||||
<span class="heading mb-4"><span id="discord-header"></span><span class="modal-close">×</span></span>
|
||||
<p class="content mb-4" id="discord-description"></p>
|
||||
<div class="row">
|
||||
@@ -376,7 +385,7 @@
|
||||
</div>
|
||||
{{ end }}
|
||||
<div id="modal-matrix" class="modal">
|
||||
<form class="modal-content card" id="form-matrix" href="">
|
||||
<form class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3" id="form-matrix" href="">
|
||||
<span class="heading">{{ .strings.linkMatrix }}</span>
|
||||
<p class="content my-4">{{ .strings.linkMatrixDescription }}</p>
|
||||
<input type="text" class="field input ~neutral @high mt-4 mb-2" placeholder="{{ .strings.matrixHomeServer }}" id="matrix-homeserver">
|
||||
@@ -415,9 +424,9 @@
|
||||
<div class="mb-4">
|
||||
<header class="flex flex-wrap items-center justify-between">
|
||||
<div>
|
||||
<span id="button-tab-invites" class="text-3xl button portal ~neutral dark:~d_neutral @low mr-2 px-5">{{ .strings.invites }}</span>
|
||||
<span id="button-tab-accounts" class="text-3xl button portal ~neutral dark:~d_neutral @low mr-2 px-5">{{ .strings.accounts }}</span>
|
||||
<span id="button-tab-settings" class="text-3xl button portal ~neutral dark:~d_neutral @low mr-2 px-5">{{ .strings.settings }}</span>
|
||||
<span id="button-tab-invites" class="text-3xl button portal ~neutral dark:~d_neutral @low mr-2 mb-2 px-5">{{ .strings.invites }}</span>
|
||||
<span id="button-tab-accounts" class="text-3xl button portal ~neutral dark:~d_neutral @low mr-2 mb-2 px-5">{{ .strings.accounts }}</span>
|
||||
<span id="button-tab-settings" class="text-3xl button portal ~neutral dark:~d_neutral @low mr-2 mb-2 px-5">{{ .strings.settings }}</span>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
@@ -433,7 +442,7 @@
|
||||
</div>
|
||||
<div class="card @low dark:~d_neutral">
|
||||
<span class="heading">{{ .strings.create }}</span>
|
||||
<div class="row" id="create-inv">
|
||||
<div class="flex flex-col md:flex-row gap-3" id="create-inv">
|
||||
<div class="card ~neutral @low col">
|
||||
<div class="row mb-2">
|
||||
<label class="col mr-2">
|
||||
@@ -607,6 +616,9 @@
|
||||
<tr>
|
||||
<th><input type="checkbox" value="" id="accounts-select-all"></th>
|
||||
<th class="table-inline my-2">{{ .strings.username }}</th>
|
||||
{{ if .jellyfinLogin }}
|
||||
<th class="text-center-i">{{ .strings.accessJFA }}</th>
|
||||
{{ end }}
|
||||
<th>{{ .strings.emailAddress }}</th>
|
||||
{{ if .telegramEnabled }}
|
||||
<th class="text-center-i">Telegram</th>
|
||||
@@ -631,17 +643,18 @@
|
||||
<div class="flex-expand">
|
||||
<div class="flex-row">
|
||||
<span class="heading">{{ .strings.settings }}</span>
|
||||
<label for="settings-advanced-enabled" class="button ~neutral @low ml-2">
|
||||
<label for="settings-advanced-enabled" class="button ~neutral @low ml-2 my-2">
|
||||
<input type="checkbox" id="settings-advanced-enabled" aria-label="Advanced settings enabled">
|
||||
<span class="ml-2">{{ .strings.advancedSettings }} </span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<span class="button ~neutral @low" id="settings-restart">{{ .strings.settingsRestart }}</span>
|
||||
<span class="button ~urge @low unfocused" id="settings-save">{{ .strings.settingsSave }}</span>
|
||||
<span class="button ~info @low my-1" id="settings-logs">{{ .strings.logs }}</span>
|
||||
<span class="button ~neutral @low my-1" id="settings-restart">{{ .strings.settingsRestart }}</span>
|
||||
<span class="button ~urge @low unfocused my-1" id="settings-save">{{ .strings.settingsSave }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="flex flex-col md:flex-row gap-3">
|
||||
<div class="card @low dark:~d_neutral col" id="settings-sidebar">
|
||||
<aside class="aside sm ~urge dark:~d_info mb-2 @low" id="settings-message">Note: <span class="badge ~critical">*</span> indicates a required field, <span class="badge ~info dark:~d_warning">R</span> indicates changes require a restart.</aside>
|
||||
<span class="button ~neutral @low settings-section-button justify-between mb-2" id="setting-about"><span class="flex">{{ .strings.aboutProgram }} <i class="ri-information-line ml-2"></i></span></span>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="{{ .cssClass }}">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="css/bundle.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/{{ .cssVersion }}bundle.css">
|
||||
{{ template "header.html" . }}
|
||||
<title>{{ .strings.successHeader }} - jfa-go</title>
|
||||
</head>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
window.matrixEnabled = {{ .matrixEnabled }};
|
||||
window.matrixRequired = {{ .matrixRequired }};
|
||||
window.matrixUserID = "{{ .matrixUser }}";
|
||||
window.captcha = {{ .captcha }};
|
||||
</script>
|
||||
{{ if .passwordReset }}
|
||||
<script src="js/pwr.js" type="module"></script>
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="{{ .cssClass }}">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="css/bundle.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/{{ .cssVersion }}bundle.css">
|
||||
{{ template "header.html" . }}
|
||||
<title>
|
||||
{{ if .passwordReset }}
|
||||
{{ .strings.passwordReset }}
|
||||
{{ else }}
|
||||
{{ .strings.pageTitle }}
|
||||
{{ end }}
|
||||
</title>
|
||||
{{ if .passwordReset }}
|
||||
<title>{{ .strings.passwordReset }}</title>
|
||||
{{ else }}
|
||||
<title>{{ .strings.pageTitle }}</title>
|
||||
{{ end }}
|
||||
</head>
|
||||
<body class="max-w-full overflow-x-hidden section">
|
||||
<div id="modal-success" class="modal">
|
||||
<div class="modal-content card">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3">
|
||||
<span class="heading mb-4">{{ if .passwordReset }}{{ .strings.passwordReset }}{{ else }}{{ .strings.successHeader }}{{ end }}</span>
|
||||
<p class="content mb-4">{{ if .passwordReset }}{{ .strings.youCanLoginPassword }}{{ else }}{{ .successMessage }}{{ end }}</p>
|
||||
<a class="button ~urge @low full-width center supra submit" href="{{ .jfLink }}" id="create-success-button">{{ .strings.continue }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div id="modal-confirmation" class="modal">
|
||||
<div class="modal-content card">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3">
|
||||
<span class="heading mb-4">{{ .strings.confirmationRequired }}</span>
|
||||
<p class="content mb-4">{{ .strings.confirmationRequiredMessage }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{{ if .telegramEnabled }}
|
||||
<div id="modal-telegram" class="modal">
|
||||
<div class="modal-content card">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3">
|
||||
<span class="heading mb-4">{{ .strings.linkTelegram }}</span>
|
||||
<p class="content mb-4">{{ .strings.sendPIN }}</p>
|
||||
<p class="text-center text-2xl mb-2">{{ .telegramPIN }}</p>
|
||||
@@ -45,7 +43,7 @@
|
||||
{{ end }}
|
||||
{{ if .discordEnabled }}
|
||||
<div id="modal-discord" class="modal">
|
||||
<div class="modal-content card">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3">
|
||||
<span class="heading mb-4">{{ .strings.linkDiscord }}</span>
|
||||
<p class="content mb-4"> {{ .discordSendPINMessage }}</p>
|
||||
<h1 class="text-center text-2xl mb-2">{{ .discordPIN }}</h1>
|
||||
@@ -56,7 +54,7 @@
|
||||
{{ end }}
|
||||
{{ if .matrixEnabled }}
|
||||
<div id="modal-matrix" class="modal">
|
||||
<div class="modal-content card">
|
||||
<div class="card relative mx-auto my-[10%] w-4/5 lg:w-1/3">
|
||||
<span class="heading mb-4">{{ .strings.linkMatrix }}</span>
|
||||
<p class="content mb-4"> {{ .strings.matrixEnterUser }}</p>
|
||||
<input type="text" class="input ~neutral @high" placeholder="@user:riot.im" id="matrix-userid">
|
||||
@@ -83,19 +81,19 @@
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="notification-box"></div>
|
||||
<div class="page-container">
|
||||
<div class="card dark:~d_neutral @low">
|
||||
<div class="row baseline">
|
||||
<span class="col heading">
|
||||
<div class="flex flex-col md:flex-row gap-3 baseline">
|
||||
<span class="heading mr-5">
|
||||
{{ if .passwordReset }}
|
||||
{{ .strings.passwordReset }}
|
||||
{{ else }}
|
||||
{{ .strings.createAccountHeader }}
|
||||
{{ end }}
|
||||
</span>
|
||||
<span class="col subheading">
|
||||
<span class="subheading">
|
||||
{{ if .passwordReset }}
|
||||
{{ .strings.enterYourPassword }}
|
||||
{{ else }}
|
||||
@@ -103,8 +101,8 @@
|
||||
{{ end }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="flex flex-col md:flex-row gap-3">
|
||||
<div class="flex-1">
|
||||
{{ if .userExpiry }}
|
||||
<aside class="col aside sm ~warning" id="user-expiry-message"></aside>
|
||||
{{ end }}
|
||||
@@ -114,36 +112,36 @@
|
||||
{{ .strings.username }}
|
||||
<input type="text" class="input ~neutral @high mt-2 mb-4" placeholder="{{ .strings.username }}" id="create-username" aria-label="{{ .strings.username }}">
|
||||
</label>
|
||||
|
||||
|
||||
<label class="label supra" for="create-email">{{ .strings.emailAddress }}</label>
|
||||
<input type="email" class="input ~neutral @high mt-2 mb-4" placeholder="{{ .strings.emailAddress }}" id="create-email" aria-label="{{ .strings.emailAddress }}" value="{{ .email }}">
|
||||
{{ if .telegramEnabled }}
|
||||
<span class="button ~info @low full-width center mb-4" id="link-telegram">{{ .strings.linkTelegram }}</span>
|
||||
<span class="button ~info @low full-width center mb-4" id="link-telegram">{{ .strings.linkTelegram }} {{ if .telegramRequired }}({{ .strings.required }}){{ end }}</span>
|
||||
{{ end }}
|
||||
{{ if .discordEnabled }}
|
||||
<span class="button ~info @low full-width center mb-4" id="link-discord">{{ .strings.linkDiscord }}</span>
|
||||
<span class="button ~info @low full-width center mb-4" id="link-discord">{{ .strings.linkDiscord }} {{ if .discordRequired }}({{ .strings.required }}){{ end }}</span>
|
||||
{{ end }}
|
||||
{{ if .matrixEnabled }}
|
||||
<span class="button ~info @low full-width center mb-4" id="link-matrix">{{ .strings.linkMatrix }}</span>
|
||||
<span class="button ~info @low full-width center mb-4" id="link-matrix">{{ .strings.linkMatrix }} {{ if .matrixRequired }}({{ .strings.required }}){{ end }}</span>
|
||||
{{ end }}
|
||||
{{ if or (.telegramEnabled) (or .discordEnabled .matrixEnabled) }}
|
||||
<div id="contact-via" class="unfocused">
|
||||
<label class="row switch pb-4">
|
||||
<input type="radio" name="contact-via" value="email"><span>Contact through Email</span>
|
||||
<label class="row switch pb-4 unfocused">
|
||||
<input type="radio" name="contact-via" value="email" id="contact-via-email" class="mr-2"><span>Contact through Email</span>
|
||||
</label>
|
||||
{{ if .telegramEnabled }}
|
||||
<label class="row switch pb-4">
|
||||
<input type="radio" name="contact-via" value="telegram" id="contact-via-telegram"><span>Contact through Telegram</span>
|
||||
<label class="row switch pb-4 unfocused">
|
||||
<input type="radio" name="contact-via" value="telegram" id="contact-via-telegram" class="mr-2"><span>Contact through Telegram</span>
|
||||
</label>
|
||||
{{ end }}
|
||||
{{ if .discordEnabled }}
|
||||
<label class="row switch pb-4">
|
||||
<input type="radio" name="contact-via" value="discord" id="contact-via-discord"><span>Contact through Discord</span>
|
||||
<label class="row switch pb-4 unfocused">
|
||||
<input type="radio" name="contact-via" value="discord" id="contact-via-discord" class="mr-2"><span>Contact through Discord</span>
|
||||
</label>
|
||||
{{ end }}
|
||||
{{ if .matrixEnabled }}
|
||||
<label class="row switch pb-4">
|
||||
<input type="radio" name="contact-via" value="matrix" id="contact-via-matrix"><span>Contact through Matrix</span>
|
||||
<label class="row switch pb-4 unfocused">
|
||||
<input type="radio" name="contact-via" value="matrix" id="contact-via-matrix" class="mr-2"><span>Contact through Matrix</span>
|
||||
</label>
|
||||
{{ end }}
|
||||
</div>
|
||||
@@ -151,7 +149,7 @@
|
||||
{{ end }}
|
||||
<label class="label supra" for="create-password">{{ .strings.password }}</label>
|
||||
<input type="password" class="input ~neutral @high mt-2 mb-4" placeholder="{{ .strings.password }}" id="create-password" aria-label="{{ .strings.password }}">
|
||||
|
||||
|
||||
<label class="label supra" for="create-reenter-password">{{ .strings.reEnterPassword }}</label>
|
||||
<input type="password" class="input ~neutral @high mt-2 mb-4" placeholder="{{ .strings.password }}" id="create-reenter-password" aria-label="{{ .strings.reEnterPassword }}">
|
||||
<label>
|
||||
@@ -166,7 +164,7 @@
|
||||
</label>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="flex-1">
|
||||
<div class="card ~neutral @low mb-4">
|
||||
<span class="label supra" for="inv-uses">{{ .strings.passwordRequirementsHeader }}</span>
|
||||
<ul>
|
||||
@@ -177,6 +175,13 @@
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ if .captcha }}
|
||||
<div class="card ~neutral @low mb-4">
|
||||
<span class="label supra mb-2">CAPTCHA <span id="captcha-regen" title="{{ .strings.refresh }}" class="badge lg @low ~info ml-2 float-right"><i class="ri-refresh-line"></i></span><span id="captcha-success" class="badge lg @low ~critical ml-2 float-right"><i class="ri-close-line"></i></span></span>
|
||||
<div id="captcha-img" class="mt-2 mb-2"></div>
|
||||
<input class="field ~neutral @low" id="captcha-input" class="mt-2" placeholder="CAPTCHA">
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if .contactMessage }}
|
||||
<aside class="col aside sm ~info mt-4">{{ .contactMessage }}</aside>
|
||||
{{ end }}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="{{ .cssClass }}">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="css/bundle.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/{{ .cssVersion }}bundle.css">
|
||||
{{ template "header.html" . }}
|
||||
<title>Invalid Code - jfa-go</title>
|
||||
</head>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="{{ .cssClass }}">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="css/bundle.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/{{ .cssVersion }}bundle.css">
|
||||
{{ template "header.html" . }}
|
||||
<title>{{ .strings.passwordReset }} - jfa-go</title>
|
||||
</head>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="light">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="css/bundle.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/{{ .cssVersion }}bundle.css">
|
||||
{{ template "header.html" . }}
|
||||
<title>{{ .lang.Strings.pageTitle }}</title>
|
||||
</head>
|
||||
@@ -139,6 +139,10 @@
|
||||
<label class="row switch pl-4 pb-4">
|
||||
<input type="checkbox" class="mr-2" id="ui-admin_only"><span>{{ .lang.Login.adminOnly }}</span>
|
||||
</label>
|
||||
<label class="row switch pl-4 pb-2">
|
||||
<input type="checkbox" class="mr-2" id="ui-allow_all"><span>{{ .lang.Login.allowAll }}</span>
|
||||
</label>
|
||||
<p class="support pb-4 pl-4 mt-1" id="description-ui-allow_all">{{ .lang.Login.allowAllDescription }}</p>
|
||||
<label class="row switch pb-4">
|
||||
<input type="radio" class="mr-2" name="ui-jellyfin_login" value="false"><span>{{ .lang.Login.authorizeManual }}</span>
|
||||
</label>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Dansk"
|
||||
"name": "Dansk (DK)"
|
||||
},
|
||||
"strings": {
|
||||
"invites": "Invitationer",
|
||||
@@ -77,7 +77,7 @@
|
||||
"settingsRequiredOrRestartMessage": "Bemærk: {n} angiver et obligatorisk felt, {n} angiver at ændringer kræver genstart.",
|
||||
"settingsSave": "Gem",
|
||||
"ombiUserDefaults": "Ombi bruger standarder",
|
||||
"ombiUserDefaultsDescription": "Opret en Ombi bruger og konfigurer den, vælg den derefter nedenfor. Brugerens indstillinger/tilladelser gemmes og anvendes på nye Ombi brugere oprettet af jfa-go",
|
||||
"ombiUserDefaultsDescription": "Opret en Ombi bruger og konfigurer den, vælg den derefter nedenfor. Brugerens indstillinger/tilladelser gemmes og anvendes på nye Ombi brugere oprettet af jfa-go når denne profil er valgt.",
|
||||
"userProfiles": "Bruger Profiler",
|
||||
"userProfilesDescription": "Profiler anvendes på brugere når de opretter en konto. En profil inkluderer adgangsrettigheder til biblioteket og layout på startskærmen.",
|
||||
"userProfilesIsDefault": "Standard",
|
||||
@@ -104,7 +104,15 @@
|
||||
"saveAsTemplate": "Gem som skabelon",
|
||||
"templates": "Skabeloner",
|
||||
"deleteTemplate": "Slet skabelon",
|
||||
"templateEnterName": "Indtast et navn for at gemme denne skabelon."
|
||||
"templateEnterName": "Indtast et navn for at gemme denne skabelon.",
|
||||
"ombiProfile": "Ombi bruger profil",
|
||||
"setExpiry": "Sæt udløb",
|
||||
"logs": "Log",
|
||||
"sendPWR": "Send Nulstilling af Adgangskode",
|
||||
"sendPWRManual": "Brugeren {n} har ingen kontaktinformation, tryk kopier for at få et link du kan sende til dem.",
|
||||
"sendPWRSuccess": "Link til nulstilling af adgangskode sendt.",
|
||||
"sendPWRSuccessManual": "Hvis brugeren ikke er modtaget den, så tryk på kopier for manuelt at sende et link til dem.",
|
||||
"sendPWRValidFor": "Dette link er gyldigt i 30m."
|
||||
},
|
||||
"notifications": {
|
||||
"changedEmailAddress": "Ændret e-mail adresse på {n}.",
|
||||
@@ -145,7 +153,9 @@
|
||||
"errorCheckUpdate": "Kunne ikke kontrollere for opdatering.",
|
||||
"updateAvailable": "En ny opdatering er tilgængelig, tjek indstillingerne.",
|
||||
"noUpdatesAvailable": "Ingen nye opdateringer tilgængelige.",
|
||||
"savedAnnouncement": "Meddelelse gemt."
|
||||
"savedAnnouncement": "Meddelelse gemt.",
|
||||
"setOmbiProfile": "Gemt i ombi profilen.",
|
||||
"errorSetOmbiProfile": "Ombi profilen kunne ikke gemmes."
|
||||
},
|
||||
"quantityStrings": {
|
||||
"modifySettingsFor": {
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
"profile": "Profile",
|
||||
"unknown": "Unknown",
|
||||
"label": "Label",
|
||||
"logs": "Logs",
|
||||
"announce": "Announce",
|
||||
"templates": "Templates",
|
||||
"subject": "Subject",
|
||||
@@ -110,7 +111,9 @@
|
||||
"matrixHomeServer": "Home server address",
|
||||
"saveAsTemplate": "Save as template",
|
||||
"deleteTemplate": "Delete template",
|
||||
"templateEnterName": "Enter a name to save this template."
|
||||
"templateEnterName": "Enter a name to save this template.",
|
||||
"accessJFA": "Access jfa-go",
|
||||
"accessJFASettings": "Cannot be changed as this either \"Admin Only\" or \"Allow All\" has been set in Settings > General."
|
||||
},
|
||||
"notifications": {
|
||||
"changedEmailAddress": "Changed email address of {n}.",
|
||||
@@ -202,6 +205,10 @@
|
||||
"singular": "Extend expiry for {n} user",
|
||||
"plural": "Extend expiry for {n} users"
|
||||
},
|
||||
"setExpiry": {
|
||||
"singular": "Set expiry for {n} user",
|
||||
"plural": "Set expiry for {n} users"
|
||||
},
|
||||
"extendedExpiry": {
|
||||
"singular": "Extended expiry for {n} user.",
|
||||
"plural": "Extended expiry for {n} users."
|
||||
|
||||
211
lang/admin/hu-hu.json
Normal file
211
lang/admin/hu-hu.json
Normal file
@@ -0,0 +1,211 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Magyar (HU)"
|
||||
},
|
||||
"strings": {
|
||||
"invites": "",
|
||||
"accounts": "",
|
||||
"settings": "",
|
||||
"inviteMonths": "",
|
||||
"inviteDays": "",
|
||||
"inviteHours": "",
|
||||
"inviteMinutes": "",
|
||||
"inviteNumberOfUses": "",
|
||||
"inviteDuration": "",
|
||||
"warning": "",
|
||||
"inviteInfiniteUsesWarning": "",
|
||||
"inviteSendToEmail": "",
|
||||
"login": "",
|
||||
"logout": "",
|
||||
"create": "",
|
||||
"apply": "",
|
||||
"delete": "",
|
||||
"add": "",
|
||||
"select": "",
|
||||
"name": "",
|
||||
"date": "",
|
||||
"enabled": "",
|
||||
"disabled": "",
|
||||
"reEnable": "",
|
||||
"setExpiry": "",
|
||||
"disable": "",
|
||||
"admin": "",
|
||||
"updates": "",
|
||||
"update": "",
|
||||
"download": "",
|
||||
"search": "",
|
||||
"advancedSettings": "",
|
||||
"lastActiveTime": "",
|
||||
"from": "",
|
||||
"user": "",
|
||||
"expiry": "",
|
||||
"userExpiry": "",
|
||||
"userExpiryDescription": "",
|
||||
"aboutProgram": "",
|
||||
"version": "",
|
||||
"commitNoun": "",
|
||||
"newUser": "",
|
||||
"profile": "",
|
||||
"unknown": "",
|
||||
"label": "",
|
||||
"logs": "",
|
||||
"announce": "",
|
||||
"templates": "",
|
||||
"subject": "",
|
||||
"message": "",
|
||||
"variables": "",
|
||||
"conditionals": "",
|
||||
"preview": "",
|
||||
"reset": "",
|
||||
"edit": "",
|
||||
"donate": "",
|
||||
"sendPWR": "",
|
||||
"contactThrough": "",
|
||||
"extendExpiry": "",
|
||||
"sendPWRManual": "",
|
||||
"sendPWRSuccess": "",
|
||||
"sendPWRSuccessManual": "",
|
||||
"sendPWRValidFor": "",
|
||||
"customizeMessages": "",
|
||||
"customizeMessagesDescription": "",
|
||||
"markdownSupported": "",
|
||||
"modifySettings": "",
|
||||
"modifySettingsDescription": "",
|
||||
"applyHomescreenLayout": "",
|
||||
"sendDeleteNotificationEmail": "",
|
||||
"sendDeleteNotifiationExample": "",
|
||||
"settingsRestart": "",
|
||||
"settingsRestarting": "",
|
||||
"settingsRestartRequired": "",
|
||||
"settingsRestartRequiredDescription": "",
|
||||
"settingsApplyRestartLater": "",
|
||||
"settingsApplyRestartNow": "",
|
||||
"settingsApplied": "",
|
||||
"settingsRefreshPage": "",
|
||||
"settingsRequiredOrRestartMessage": "",
|
||||
"settingsSave": "",
|
||||
"ombiProfile": "",
|
||||
"ombiUserDefaultsDescription": "",
|
||||
"userProfiles": "",
|
||||
"userProfilesDescription": "",
|
||||
"userProfilesIsDefault": "",
|
||||
"userProfilesLibraries": "",
|
||||
"addProfile": "",
|
||||
"addProfileDescription": "",
|
||||
"addProfileNameOf": "",
|
||||
"addProfileStoreHomescreenLayout": "",
|
||||
"inviteNoUsersCreated": "",
|
||||
"inviteUsersCreated": "",
|
||||
"inviteNoProfile": "",
|
||||
"inviteDateCreated": "",
|
||||
"inviteRemainingUses": "",
|
||||
"inviteNoInvites": "",
|
||||
"inviteExpiresInTime": "",
|
||||
"notifyEvent": "",
|
||||
"notifyInviteExpiry": "",
|
||||
"notifyUserCreation": "",
|
||||
"sendPIN": "",
|
||||
"searchDiscordUser": "",
|
||||
"findDiscordUser": "",
|
||||
"linkMatrixDescription": "",
|
||||
"matrixHomeServer": "",
|
||||
"saveAsTemplate": "",
|
||||
"deleteTemplate": "",
|
||||
"templateEnterName": ""
|
||||
},
|
||||
"notifications": {
|
||||
"changedEmailAddress": "",
|
||||
"userCreated": "",
|
||||
"createProfile": "",
|
||||
"saveSettings": "",
|
||||
"saveEmail": "",
|
||||
"sentAnnouncement": "",
|
||||
"savedAnnouncement": "",
|
||||
"setOmbiProfile": "",
|
||||
"updateApplied": "",
|
||||
"updateAppliedRefresh": "",
|
||||
"telegramVerified": "",
|
||||
"accountConnected": "",
|
||||
"errorConnection": "",
|
||||
"error401Unauthorized": "",
|
||||
"errorSettingsAppliedNoHomescreenLayout": "",
|
||||
"errorHomescreenAppliedNoSettings": "",
|
||||
"errorSettingsFailed": "",
|
||||
"errorLoginBlank": "",
|
||||
"errorUnknown": "",
|
||||
"errorSaveEmail": "",
|
||||
"errorBlankFields": "",
|
||||
"errorDeleteProfile": "",
|
||||
"errorLoadProfiles": "",
|
||||
"errorCreateProfile": "",
|
||||
"errorSetDefaultProfile": "",
|
||||
"errorLoadUsers": "",
|
||||
"errorSaveSettings": "",
|
||||
"errorLoadSettings": "",
|
||||
"errorSetOmbiProfile": "",
|
||||
"errorLoadOmbiUsers": "",
|
||||
"errorChangedEmailAddress": "",
|
||||
"errorFailureCheckLogs": "",
|
||||
"errorPartialFailureCheckLogs": "",
|
||||
"errorUserCreated": "",
|
||||
"errorSendWelcomeEmail": "",
|
||||
"errorApplyUpdate": "",
|
||||
"errorCheckUpdate": "",
|
||||
"updateAvailable": "",
|
||||
"noUpdatesAvailable": ""
|
||||
},
|
||||
"quantityStrings": {
|
||||
"modifySettingsFor": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"deleteNUsers": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"disableUsers": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"reEnableUsers": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"addUser": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"deleteUser": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"deletedUser": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"disabledUser": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"enabledUser": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"announceTo": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"appliedSettings": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"extendExpiry": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"extendedExpiry": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,8 @@
|
||||
"sendPWR": "Verstuur wachtwoordreset",
|
||||
"sendPWRSuccess": "Wachtwoordreset-link verstuurd.",
|
||||
"sendPWRValidFor": "De link is 30m geldig.",
|
||||
"ombiProfile": "Ombi gebruikersprofiel"
|
||||
"ombiProfile": "Ombi gebruikersprofiel",
|
||||
"logs": "Logs"
|
||||
},
|
||||
"notifications": {
|
||||
"changedEmailAddress": "E-mailadres van {n} gewijzigd.",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Dansk"
|
||||
"name": "Dansk (DK)"
|
||||
},
|
||||
"strings": {
|
||||
"username": "Brugernavn",
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
"linkDiscord": "Link Discord",
|
||||
"linkMatrix": "Link Matrix",
|
||||
"contactDiscord": "Contact through Discord",
|
||||
"theme": "Theme"
|
||||
"theme": "Theme",
|
||||
"refresh": "Refresh",
|
||||
"required": "Required"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Dansk"
|
||||
"name": "Dansk (DK)"
|
||||
},
|
||||
"strings": {
|
||||
"ifItWasNotYou": "Ignorer venligst hvis dette ikke var dig.",
|
||||
@@ -12,14 +12,14 @@
|
||||
"title": "Meddelelse: Bruger oprettet",
|
||||
"aUserWasCreated": "En bruger blev oprettet med koden {code}.",
|
||||
"time": "Tid",
|
||||
"notificationNotice": "Meddelelse: Notifikations e-mails kan blive ændret på admin-siden."
|
||||
"notificationNotice": "Bemærk: Notifikations beskeder kan blive ændret på admin-siden."
|
||||
},
|
||||
"inviteExpiry": {
|
||||
"name": "Invitationens udløb",
|
||||
"title": "Meddelelse: Invitation udløbet",
|
||||
"inviteExpired": "Invitation udløbet.",
|
||||
"expiredAt": "Koden {code} udløber om {time}.",
|
||||
"notificationNotice": "Meddelelse: Notifikations e-mails kan blive ændret på admin-siden."
|
||||
"notificationNotice": "Bemærk: Notifikations beskeder kan blive ændret på admin-siden."
|
||||
},
|
||||
"passwordReset": {
|
||||
"name": "Nulstil Adgangskode",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Dansk"
|
||||
"name": "Dansk (DK)"
|
||||
},
|
||||
"strings": {
|
||||
"pageTitle": "Opret Jellyfin Konto",
|
||||
"pageTitle": "Opret en Jellyfin Konto",
|
||||
"createAccountHeader": "Opret Konto",
|
||||
"accountDetails": "Detaljer",
|
||||
"emailAddress": "E-mail",
|
||||
@@ -17,9 +17,9 @@
|
||||
"confirmationRequired": "E-mail bekræftelse er påkrævet",
|
||||
"confirmationRequiredMessage": "Tjek venligst din e-mail indbakke for at verificere din adresse.",
|
||||
"yourAccountIsValidUntil": "Din konto er gyldig indtil {date}.",
|
||||
"sendPIN": "Send nedenstående pinkode til botten, og kom derefter tilbage her for at linke din konto.",
|
||||
"sendPINDiscord": "Skriv {command} i {server_channel} på Discord, og send PIN-koden nedenfor via. DM til boten.",
|
||||
"matrixEnterUser": "Skriv dit Bruger ID, tryk Indsend, og en PIN-kode vil blive sendt til dig. Skriv den her efter for at fortsætte."
|
||||
"sendPIN": "Send nedenstående pinkode til botten, og kom derefter tilbage her for at sammenkoble din konto.",
|
||||
"sendPINDiscord": "Skriv {command} i {server_channel} på Discord, og send PIN-koden nedenfor via. DM til botten.",
|
||||
"matrixEnterUser": "Skriv dit Bruger ID, tryk Indsend, og en PIN-kode vil blive sendt til dig. Skriv den her efter, for at fortsætte."
|
||||
},
|
||||
"notifications": {
|
||||
"errorUserExists": "Brugeren eksistere allerede.",
|
||||
@@ -29,7 +29,8 @@
|
||||
"errorMatrixVerification": "Matrix verifikation påkrævet.",
|
||||
"errorInvalidPIN": "PIN-koden er ugyldig.",
|
||||
"errorUnknown": "Ukendt fejl.",
|
||||
"verified": "konto verificeret."
|
||||
"verified": "Konto verificeret.",
|
||||
"errorNoEmail": "E-mail er påkrævet."
|
||||
},
|
||||
"validationStrings": {
|
||||
"length": {
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
"errorDiscordVerification": "Discord-Verifizierung erforderlich.",
|
||||
"errorMatrixVerification": "Matrix-Verifizierung erforderlich.",
|
||||
"errorUnknown": "Unbekannter Fehler.",
|
||||
"verified": "Konto verifiziert."
|
||||
"verified": "Konto verifiziert.",
|
||||
"errorNoEmail": "E-Mail Adresse erforderlich."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"confirmationRequiredMessage": "Please check your email inbox to verify your address.",
|
||||
"yourAccountIsValidUntil": "Your account will be valid until {date}.",
|
||||
"sendPIN": "Send the PIN below to the bot, then come back here to link your account.",
|
||||
"sendPINDiscord": "Type {command} in {server_channel} on Discord, then send the PIN below via DM to the bot.",
|
||||
"sendPINDiscord": "Type {command} in {server_channel} on Discord, then send the PIN below.",
|
||||
"matrixEnterUser": "Enter your User ID, press submit, and a PIN will be sent to you. Enter it here to continue."
|
||||
},
|
||||
"notifications": {
|
||||
@@ -30,6 +30,9 @@
|
||||
"errorInvalidPIN": "PIN is invalid.",
|
||||
"errorUnknown": "Unknown error.",
|
||||
"errorNoEmail": "Email required.",
|
||||
"errorCaptcha": "Captcha incorrect.",
|
||||
"errorPassword": "Check password requirements.",
|
||||
"errorNoMatch": "Passwords don't match.",
|
||||
"verified": "Account verified."
|
||||
},
|
||||
"validationStrings": {
|
||||
|
||||
57
lang/form/hu-hu.json
Normal file
57
lang/form/hu-hu.json
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Magyar (HU)"
|
||||
},
|
||||
"strings": {
|
||||
"pageTitle": "Jellyfin fiók létrehozása",
|
||||
"createAccountHeader": "Fiók létrehozása",
|
||||
"accountDetails": "Részletek",
|
||||
"emailAddress": "E-mail",
|
||||
"username": "Felhasználónév",
|
||||
"password": "Jelszó",
|
||||
"reEnterPassword": "Jelszó megerősítése",
|
||||
"reEnterPasswordInvalid": "A jelszók nem egyeznek",
|
||||
"createAccountButton": "Fiók létrehozása",
|
||||
"passwordRequirementsHeader": "Jelszó követelmények",
|
||||
"successHeader": "Siker!",
|
||||
"confirmationRequired": "E-mail megerősítés szükséges",
|
||||
"confirmationRequiredMessage": "Kérjük ellenőrizze az e-mail címére küldött üzenetet, a fiók ellenőrzéséhez.",
|
||||
"yourAccountIsValidUntil": "A fiókja eddig lesz érvényes: {date}.",
|
||||
"sendPIN": "Az alábbi kódot küldje el a botnak, majd itt csatolja össze a fiókját.",
|
||||
"sendPINDiscord": "Discordon haszánlja a {command} parancsot, a {server_channel} csatornában, majd küldje el a kódot a botnak privát üzenetben.",
|
||||
"matrixEnterUser": "Írja be a felhasználója azonosítóját majd nyomja meg a beküldés gombot. A kapott kódot ide írja be."
|
||||
},
|
||||
"notifications": {
|
||||
"errorUserExists": "A felhasználó már létezik.",
|
||||
"errorInvalidCode": "Érvénytelen meghívó kód.",
|
||||
"errorTelegramVerification": "Telegram ellenőrzés szükséges.",
|
||||
"errorDiscordVerification": "Discord ellenőrzés szükséges.",
|
||||
"errorMatrixVerification": "Matrix ellenőrzés szükséges.",
|
||||
"errorInvalidPIN": "A PIN-kód érvénytelen.",
|
||||
"errorUnknown": "Ismeretlen hiba.",
|
||||
"errorNoEmail": "E-mail szükséges.",
|
||||
"verified": "Fiók ellenőrizve."
|
||||
},
|
||||
"validationStrings": {
|
||||
"length": {
|
||||
"singular": "Legalább {n} karakter",
|
||||
"plural": "Legalább {n} karakter."
|
||||
},
|
||||
"uppercase": {
|
||||
"singular": "Legalább {n} nagybetűs karakter",
|
||||
"plural": "Legalább {n} nagybetűs karakter"
|
||||
},
|
||||
"lowercase": {
|
||||
"singular": "Legalább {n} kisbetüs karakter",
|
||||
"plural": "Legalább {n} kisbetüs karakter"
|
||||
},
|
||||
"number": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
},
|
||||
"special": {
|
||||
"singular": "",
|
||||
"plural": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Dansk"
|
||||
"name": "Dansk (DK)"
|
||||
},
|
||||
"strings": {
|
||||
"passwordReset": "Nulstil adgangskode",
|
||||
@@ -10,6 +10,7 @@
|
||||
"youCanLogin": "Du kan nu logge ind med koden nedenfor som din adgangskode.",
|
||||
"youCanLoginOmbi": "Du kan nu logge ind på Jellyfin & Ombi med koden nedenfor som din adgangskode.",
|
||||
"changeYourPassword": "Sørg for at ændre din adgangskode, når du har logget ind.",
|
||||
"enterYourPassword": "Indtast din nye adgangskode nedenfor."
|
||||
"enterYourPassword": "Indtast din nye adgangskode nedenfor.",
|
||||
"youCanLoginPassword": "Du kan nu logge ind med din nye adgangskode. Tryk nedenfor for at fortsætte til Jellyfin."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Dansk"
|
||||
"name": "Dansk (DK)"
|
||||
},
|
||||
"strings": {
|
||||
"pageTitle": "Opsæt - jfa-go",
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
"authorizeWithJellyfin": "Authorize with Jellyfin/Emby: Login details are shared with Jellyfin, which allows for multiple users.",
|
||||
"authorizeManual": "Username and Password: Manually set the username and password.",
|
||||
"adminOnly": "Admin users only (recommended)",
|
||||
"allowAll": "Allow all Jellyfin users to login",
|
||||
"allowAllDescription": "Not recommended, you should allow individual users to login once setup.",
|
||||
"emailNotice": "Your email address can be used to receive notifications."
|
||||
},
|
||||
"jellyfinEmby": {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Dansk"
|
||||
"name": "Dansk (DK)"
|
||||
},
|
||||
"strings": {
|
||||
"startMessage": "Hej!\nIndtast din Jellyfin PIN-kode her for at verificere din konto.",
|
||||
"matrixStartMessage": "Hej!\nIndtast PIN-koden under ind i Jellyfin tilmeldingssiden for at verificere din konto.",
|
||||
"matrixStartMessage": "Hej!\nIndtast PIN-koden på Jellyfin tilmeldingssiden for at verificere din konto.",
|
||||
"invalidPIN": "Den PIN-kode var ugyldig, prøv igen.",
|
||||
"pinSuccess": "Sådan! Du kan nu gå tilbage til tilmeldingssiden.",
|
||||
"languageMessage": "Meddelelse: Se tilgængelige sprog med {command}, og vælg sprog med {command} <sprog kode>."
|
||||
"languageMessage": "Note: Se tilgængelige sprog med {command}, og vælg sprog med {command} <sprog kode>."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,13 @@
|
||||
},
|
||||
"strings": {
|
||||
"startMessage": "Hi!\nEnter your Jellyfin PIN code here to verify your account.",
|
||||
"discordStartMessage": "Hi!\n Enter your PIN with `/pin <PIN>` to verify your account.",
|
||||
"matrixStartMessage": "Hi\nEnter the below PIN in the Jellyfin sign-up page to verify your account.",
|
||||
"invalidPIN": "That PIN was invalid, try again.",
|
||||
"pinSuccess": "Success! You can now return to the sign-up page.",
|
||||
"languageMessage": "Note: See available languages with {command}, and set language with {command} <language code>."
|
||||
"languageMessage": "Note: See available languages with {command}, and set language with {command} <language code>.",
|
||||
"languageMessageDiscord": "Note: set your language with /lang <language name>.",
|
||||
"languageSet": "Language set to {language}.",
|
||||
"discordDMs": "Please check your DMs for a response."
|
||||
}
|
||||
}
|
||||
|
||||
2
main.go
2
main.go
@@ -622,7 +622,7 @@ func flagPassed(name string) (found bool) {
|
||||
}
|
||||
|
||||
// @title jfa-go internal API
|
||||
// @version 0.3.10
|
||||
// @version 0.4.0
|
||||
// @description API for the jfa-go frontend
|
||||
// @contact.name Harvey Tindall
|
||||
// @contact.email hrfee@hrfee.dev
|
||||
|
||||
@@ -14,6 +14,7 @@ func runMigrations(app *appContext) {
|
||||
migrateBootstrap(app)
|
||||
migrateEmailStorage(app)
|
||||
migrateNotificationMethods(app)
|
||||
linkExistingOmbiDiscordTelegram(app)
|
||||
// migrateHyphens(app)
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ func migrateEmailStorage(app *appContext) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Pre-0.3.10, Admin notifications for invites were indexed by and only sent to email addresses. Now, when Jellyfin Login is enabled, They are indexed by the admin's Jellyfin ID, and send by any method enabled for them. This migrates storage to that format.
|
||||
// Pre-0.4.0, Admin notifications for invites were indexed by and only sent to email addresses. Now, when Jellyfin Login is enabled, They are indexed by the admin's Jellyfin ID, and send by any method enabled for them. This migrates storage to that format.
|
||||
func migrateNotificationMethods(app *appContext) error {
|
||||
if !app.config.Section("ui").Key("jellyfin_login").MustBool(false) {
|
||||
return nil
|
||||
@@ -158,6 +159,41 @@ func migrateNotificationMethods(app *appContext) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Pre-0.4.0, Ombi users were created without linking their Discord & Telegram accounts. This will add them.
|
||||
func linkExistingOmbiDiscordTelegram(app *appContext) error {
|
||||
if !discordEnabled && !telegramEnabled {
|
||||
return nil
|
||||
}
|
||||
if !app.config.Section("ombi").Key("enabled").MustBool(false) {
|
||||
return nil
|
||||
}
|
||||
idList := map[string][2]string{}
|
||||
for jfID, user := range app.storage.discord {
|
||||
idList[jfID] = [2]string{user.ID, ""}
|
||||
}
|
||||
for jfID, user := range app.storage.telegram {
|
||||
vals, ok := idList[jfID]
|
||||
if !ok {
|
||||
vals = [2]string{"", ""}
|
||||
}
|
||||
vals[1] = user.Username
|
||||
idList[jfID] = vals
|
||||
}
|
||||
for jfID, ids := range idList {
|
||||
ombiUser, status, err := app.getOmbiUser(jfID)
|
||||
if status != 200 || err != nil {
|
||||
app.debug.Printf("Failed to get Ombi user with Discord/Telegram \"%s\"/\"%s\" (%d): %v", ids[0], ids[1], status, err)
|
||||
continue
|
||||
}
|
||||
_, status, err = app.ombi.SetNotificationPrefs(ombiUser, ids[0], ids[1])
|
||||
if status != 200 || err != nil {
|
||||
app.debug.Printf("Failed to set prefs for Ombi user \"%s\" (%d): %v", ombiUser["userName"].(string), status, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Migrate between hyphenated & non-hyphenated user IDs. Doesn't seem to happen anymore, so disabled.
|
||||
// func migrateHyphens(app *appContext) {
|
||||
// checkVersion := func(version string) int {
|
||||
|
||||
14
models.go
14
models.go
@@ -23,6 +23,8 @@ type newUserDTO struct {
|
||||
DiscordContact bool `json:"discord_contact"` // Whether or not to use discord for notifications/pwrs
|
||||
MatrixPIN string `json:"matrix_pin" example:"A1-B2-3C"` // Matrix verification PIN (if used)
|
||||
MatrixContact bool `json:"matrix_contact"` // Whether or not to use matrix for notifications/pwrs
|
||||
CaptchaID string `json:"captcha_id"` // Captcha ID (if enabled)
|
||||
CaptchaText string `json:"captcha_text"` // Captcha text (if enabled)
|
||||
}
|
||||
|
||||
type newUserResponse struct {
|
||||
@@ -145,6 +147,8 @@ type respUser struct {
|
||||
NotifyThroughDiscord bool `json:"notify_discord"`
|
||||
Matrix string `json:"matrix"` // Matrix ID (if known)
|
||||
NotifyThroughMatrix bool `json:"notify_matrix"`
|
||||
Label string `json:"label"` // Label of user, shown next to their name.
|
||||
AccountsAdmin bool `json:"accounts_admin"` // Whether or not the user is a jfa-go admin.
|
||||
}
|
||||
|
||||
type getUsersDTO struct {
|
||||
@@ -341,3 +345,13 @@ type InternalPWR struct {
|
||||
ID string `json:"id"`
|
||||
Expiry time.Time `json:"expiry"`
|
||||
}
|
||||
|
||||
type LogDTO struct {
|
||||
Log string `json:"log"`
|
||||
}
|
||||
|
||||
type setAccountsAdminDTO map[string]bool
|
||||
|
||||
type genCaptchaDTO struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
35
ombi/ombi.go
35
ombi/ombi.go
@@ -13,6 +13,11 @@ import (
|
||||
"github.com/hrfee/jfa-go/common"
|
||||
)
|
||||
|
||||
const (
|
||||
NotifAgentDiscord = 1
|
||||
NotifAgentTelegram = 4
|
||||
)
|
||||
|
||||
// Ombi represents a running Ombi instance.
|
||||
type Ombi struct {
|
||||
server, key string
|
||||
@@ -81,7 +86,7 @@ func (ombi *Ombi) getJSON(url string, params map[string]string) (string, int, er
|
||||
}
|
||||
|
||||
// does a POST and optionally returns response as string. Returns a string instead of an io.reader bcs i couldn't get it working otherwise.
|
||||
func (ombi *Ombi) send(mode string, url string, data map[string]interface{}, response bool) (string, int, error) {
|
||||
func (ombi *Ombi) send(mode string, url string, data interface{}, response bool, headers map[string]string) (string, int, error) {
|
||||
responseText := ""
|
||||
params, _ := json.Marshal(data)
|
||||
req, _ := http.NewRequest(mode, url, bytes.NewBuffer(params))
|
||||
@@ -89,6 +94,9 @@ func (ombi *Ombi) send(mode string, url string, data map[string]interface{}, res
|
||||
for name, value := range ombi.header {
|
||||
req.Header.Add(name, value)
|
||||
}
|
||||
for name, value := range headers {
|
||||
req.Header.Add(name, value)
|
||||
}
|
||||
resp, err := ombi.httpClient.Do(req)
|
||||
defer ombi.timeoutHandler()
|
||||
if err != nil || !(resp.StatusCode == 200 || resp.StatusCode == 201) {
|
||||
@@ -117,11 +125,11 @@ func (ombi *Ombi) send(mode string, url string, data map[string]interface{}, res
|
||||
}
|
||||
|
||||
func (ombi *Ombi) post(url string, data map[string]interface{}, response bool) (string, int, error) {
|
||||
return ombi.send("POST", url, data, response)
|
||||
return ombi.send("POST", url, data, response, nil)
|
||||
}
|
||||
|
||||
func (ombi *Ombi) put(url string, data map[string]interface{}, response bool) (string, int, error) {
|
||||
return ombi.send("PUT", url, data, response)
|
||||
return ombi.send("PUT", url, data, response, nil)
|
||||
}
|
||||
|
||||
// ModifyUser applies the given modified user object to the corresponding user.
|
||||
@@ -220,3 +228,24 @@ func (ombi *Ombi) NewUser(username, password, email string, template map[string]
|
||||
ombi.cacheExpiry = time.Now()
|
||||
return nil, code, err
|
||||
}
|
||||
|
||||
type NotificationPref struct {
|
||||
Agent int `json:"agent"`
|
||||
UserID string `json:"userId"`
|
||||
Value string `json:"value"`
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
func (ombi *Ombi) SetNotificationPrefs(user map[string]interface{}, discordID, telegramUser string) (result string, code int, err error) {
|
||||
id := user["id"].(string)
|
||||
url := fmt.Sprintf("%s/api/v1/Identity/NotificationPreferences", ombi.server)
|
||||
var data []NotificationPref
|
||||
if discordID != "" {
|
||||
data = []NotificationPref{NotificationPref{NotifAgentDiscord, id, discordID, true}}
|
||||
}
|
||||
if telegramUser != "" {
|
||||
data = append(data, NotificationPref{NotifAgentTelegram, id, telegramUser, true})
|
||||
}
|
||||
result, code, err = ombi.send("POST", url, data, true, map[string]string{"UserName": user["userName"].(string)})
|
||||
return
|
||||
}
|
||||
|
||||
1729
package-lock.json
generated
1729
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -21,12 +21,16 @@
|
||||
"@types/node": "^15.0.1",
|
||||
"a17t": "^0.10.1",
|
||||
"browserslist": "^4.16.6",
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"esbuild": "^0.8.57",
|
||||
"fs-cheerio": "^3.0.0",
|
||||
"inline-source": "^7.2.0",
|
||||
"jsdom": "^19.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"mjml": "^4.8.0",
|
||||
"mjml": "^4.12.0",
|
||||
"nightwind": "github:yonson2/nightwind",
|
||||
"perl-regex": "^1.0.4",
|
||||
"postcss": "^8.4.5",
|
||||
"remixicon": "^2.5.0",
|
||||
"remove-markdown": "^0.3.0",
|
||||
"typescript": "^4.0.3",
|
||||
@@ -34,6 +38,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"live-server": "^1.2.1",
|
||||
"tailwindcss": "^3.0.8"
|
||||
"tailwindcss": "^3.0.16"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +121,11 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
||||
router.POST(p+"/newUser", app.NewUser)
|
||||
router.Use(static.Serve(p+"/invite/", app.webFS))
|
||||
router.GET(p+"/invite/:invCode", app.InviteProxy)
|
||||
if app.config.Section("captcha").Key("enabled").MustBool(false) {
|
||||
router.GET(p+"/captcha/gen/:invCode", app.GenCaptcha)
|
||||
router.GET(p+"/captcha/img/:invCode/:captchaID", app.GetCaptcha)
|
||||
router.POST(p+"/captcha/verify/:invCode/:captchaID/:text", app.VerifyCaptcha)
|
||||
}
|
||||
if telegramEnabled {
|
||||
router.GET(p+"/invite/:invCode/telegram/verified/:pin", app.TelegramVerifiedInvite)
|
||||
}
|
||||
@@ -160,6 +165,8 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
||||
api.DELETE(p+"/profiles", app.DeleteProfile)
|
||||
api.POST(p+"/invites/notify", app.SetNotify)
|
||||
api.POST(p+"/users/emails", app.ModifyEmails)
|
||||
api.POST(p+"/users/labels", app.ModifyLabels)
|
||||
api.POST(p+"/users/accounts-admin", app.SetAccountsAdmin)
|
||||
// api.POST(p + "/setDefaults", app.SetDefaults)
|
||||
api.POST(p+"/users/settings", app.ApplySettings)
|
||||
api.POST(p+"/users/announce", app.Announce)
|
||||
@@ -180,6 +187,7 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
||||
api.GET(p+"/config", app.GetConfig)
|
||||
api.POST(p+"/config", app.ModifyConfig)
|
||||
api.POST(p+"/restart", app.restart)
|
||||
api.GET(p+"/logs", app.GetLog)
|
||||
if telegramEnabled || discordEnabled || matrixEnabled {
|
||||
api.GET(p+"/telegram/pin", app.TelegramGetPin)
|
||||
api.GET(p+"/telegram/verified/:pin", app.TelegramVerified)
|
||||
|
||||
@@ -2,51 +2,49 @@
|
||||
|
||||
# scan all typescript and automatically add dark variants to color tags if they're not already present.
|
||||
|
||||
if [[ "$1" == "ts" ]]; then
|
||||
for f in $2/*.ts; do
|
||||
# FIXME: inline html
|
||||
for l in $(grep -n "~neutral\|~positive\|~urge\|~warning\|~info\|~critical" $f | sed -e 's/:.*//g'); do
|
||||
# for l in $(sed -n '/classList/=' $f); do
|
||||
line=$(sed -n "${l}p" $f)
|
||||
echo $line | grep "classList" &> /dev/null
|
||||
for f in $1/*.ts; do
|
||||
# FIXME: inline html
|
||||
for l in $(grep -n "~neutral\|~positive\|~urge\|~warning\|~info\|~critical" $f | sed -e 's/:.*//g'); do
|
||||
# for l in $(sed -n '/classList/=' $f); do
|
||||
line=$(sed -n "${l}p" $f)
|
||||
echo $line | grep "classList" &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo $line | sed 's/.*classList//; s/).*//' | grep "~neutral\|~positive\|~urge\|~warning\|~info\|~critical" &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo $line | sed 's/.*classList//; s/).*//' | grep "~neutral\|~positive\|~urge\|~warning\|~info\|~critical" &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# echo "found classList @ " $l
|
||||
echo $line | grep "dark:" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
for color in neutral positive urge warning info critical; do
|
||||
sed -i "${l},${l}s/\"~${color}\"/\"~${color}\", \"dark:~d_${color}\"/g" $f
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo "FIX: classList found, but color tag wasn't in it"
|
||||
# echo "found classList @ " $l
|
||||
echo $line | grep "dark:" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
for color in neutral positive urge warning info critical; do
|
||||
sed -i "${l},${l}s/\"~${color}\"/\"~${color}\", \"dark:~d_${color}\"/g" $f
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo $line | grep "querySelector" &> /dev/null
|
||||
echo "FIX: classList found, but color tag wasn't in it"
|
||||
fi
|
||||
else
|
||||
echo $line | grep "querySelector" &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
# echo "found inline in " $f " @ " $l ", " $(sed -n "${l}p" $f)
|
||||
echo $line | grep "dark:" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
for color in neutral positive urge warning info critical; do
|
||||
sed -i "${l},${l}s/~${color}/~${color} dark:~d_${color}/g" $f
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo $line | sed 's/.*querySelector//; s/).*//' | grep "~neutral\|~positive\|~urge\|~warning\|~info\|~critical" &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
# echo "found inline in " $f " @ " $l ", " $(sed -n "${l}p" $f)
|
||||
echo $line | grep "dark:" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
# echo "found inline in " $f " @ " $l ", " $(sed -n "${l}p" $f)
|
||||
for color in neutral positive urge warning info critical; do
|
||||
sed -i "${l},${l}s/~${color}/~${color} dark:~d_${color}/g" $f
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo $line | sed 's/.*querySelector//; s/).*//' | grep "~neutral\|~positive\|~urge\|~warning\|~info\|~critical" &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo $line | grep "dark:" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
# echo "found inline in " $f " @ " $l ", " $(sed -n "${l}p" $f)
|
||||
for color in neutral positive urge warning info critical; do
|
||||
sed -i "${l},${l}s/~${color}/~${color} dark:~d_${color}/g" $f
|
||||
done
|
||||
fi
|
||||
#else
|
||||
#echo "FIX: querySelector found, but color tag wasn't in it: " $line
|
||||
fi
|
||||
#else
|
||||
#echo "FIX: querySelector found, but color tag wasn't in it: " $line
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1,56 +1,89 @@
|
||||
let parser = require("jsdom");
|
||||
let parser = require("cheerio");
|
||||
let fs = require("fs");
|
||||
let path = require("path");
|
||||
let pre = require("perl-regex");
|
||||
|
||||
const template = process.env.NOTEMPLATE != "1";
|
||||
|
||||
const hasDark = (item) => {
|
||||
for (let i = 0; i < item.classList.length; i++) {
|
||||
if (item.classList[i].substring(0,5) == "dark:") {
|
||||
let list = item.attr("class").split(/\s+/);
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (list[i].substring(0,5) == "dark:") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (typeof String.prototype.replaceAll === "undefined") {
|
||||
String.prototype.replaceAll = function(match, replace) {
|
||||
return this.replace(new RegExp(match, 'g'), () => replace);
|
||||
}
|
||||
}
|
||||
|
||||
const fixHTML = (infile, outfile) => {
|
||||
console.log(infile, outfile)
|
||||
let doc = new parser.JSDOM(fs.readFileSync(infile));
|
||||
function fixHTML(infile, outfile) {
|
||||
let f = fs.readFileSync(infile).toString();
|
||||
// Find all go template strings ({{ example }})
|
||||
let templateStrings = pre.exec(f, "(?s){{(?:(?!{{).)*?}}", "gi");
|
||||
if (template) {
|
||||
for (let i = 0; i < templateStrings.length; i++) {
|
||||
let s = templateStrings[i].replace(/\\/g, '');
|
||||
// let s = templateStrings[i];
|
||||
f = f.replaceAll(s, "<!--" + s.slice(3).slice(0, -3) + "-->");
|
||||
}
|
||||
}
|
||||
let doc = new parser.load(f);
|
||||
for (let item of ["badge", "chip", "shield", "input", "table", "button", "portal", "select", "aside", "card", "field", "textarea"]) {
|
||||
let items = doc.window.document.body.querySelectorAll("."+item);
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
let items = doc("."+item);
|
||||
items.each((i, elem) => {
|
||||
let hasColor = false;
|
||||
for (let color of ["neutral", "positive", "urge", "warning", "info", "critical"]) {
|
||||
//console.log(color);
|
||||
if (items[i].classList.contains("~"+color)) {
|
||||
if (doc(elem).hasClass("~"+color)) {
|
||||
hasColor = true;
|
||||
// console.log("adding to", items[i].classList)
|
||||
if (!hasDark(items[i])) {
|
||||
items[i].classList.add("dark:~d_"+color);
|
||||
if (!hasDark(doc(elem))) {
|
||||
doc(elem).addClass("dark:~d_"+color);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasColor) {
|
||||
if (!hasDark(items[i])) {
|
||||
if (!hasDark(doc(elem))) {
|
||||
// card without ~neutral look different than with.
|
||||
if (item != "card") items[i].classList.add("~neutral");
|
||||
items[i].classList.add("dark:~d_neutral");
|
||||
if (item != "card") doc(elem).addClass("~neutral");
|
||||
doc(elem).addClass("dark:~d_neutral");
|
||||
}
|
||||
}
|
||||
if (!items[i].classList.contains("@low") && !items[i].classList.contains("@high")) {
|
||||
items[i].classList.add("@low");
|
||||
if (!doc(elem).hasClass("@low") && !doc(elem).hasClass("@high")) {
|
||||
doc(elem).addClass("@low");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
fs.writeFileSync(outfile, doc.window.document.documentElement.outerHTML);
|
||||
let out = doc.html();
|
||||
// let out = f
|
||||
if (template) {
|
||||
for (let i = 0; i < templateStrings.length; i++) {
|
||||
let s = templateStrings[i].replace(/\\/g, '');
|
||||
out = out.replaceAll("<!--" + s.slice(3).slice(0, -3) + "-->", s);
|
||||
}
|
||||
out = out.replaceAll("<!--", "{{");
|
||||
out = out.replaceAll("-->", "}}");
|
||||
}
|
||||
fs.writeFileSync(outfile, out);
|
||||
console.log(infile, outfile);
|
||||
};
|
||||
|
||||
let inpath = process.argv[process.argv.length-2];
|
||||
let outpath = process.argv[process.argv.length-1];
|
||||
|
||||
let files = fs.readdirSync(inpath);
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
if (files[i].indexOf(".html")>=0) {
|
||||
fixHTML(path.join(inpath, files[i]), path.join(outpath, files[i]));
|
||||
if (fs.statSync(inpath).isDirectory()) {
|
||||
let files = fs.readdirSync(inpath);
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
if (files[i].indexOf(".html")>=0) {
|
||||
fixHTML(path.join(inpath, files[i]), path.join(outpath, files[i]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fixHTML(inpath, outpath);
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
# sets version environment variable for goreleaser to use
|
||||
# scripts/version.sh goreleaser ...
|
||||
JFA_GO_VERSION=$(git describe --exact-match HEAD 2> /dev/null || echo 'vgit')
|
||||
JFA_GO_NFPM_EPOCH=$(git rev-list --all --count) JFA_GO_VERSION="$(echo $JFA_GO_VERSION | sed 's/v//g')" $@
|
||||
JFA_GO_CSS_VERSION="v3" JFA_GO_NFPM_EPOCH=$(git rev-list --all --count) JFA_GO_VERSION="$(echo $JFA_GO_VERSION | sed 's/v//g')" $@
|
||||
|
||||
9
setup.go
9
setup.go
@@ -38,10 +38,11 @@ func (app *appContext) ServeSetup(gc *gin.Context) {
|
||||
return
|
||||
}
|
||||
gc.HTML(200, "setup.html", gin.H{
|
||||
"lang": app.storage.lang.Setup[lang],
|
||||
"emailLang": app.storage.lang.Email[emailLang],
|
||||
"language": app.storage.lang.Setup[lang].JSON,
|
||||
"messages": string(msg),
|
||||
"cssVersion": cssVersion,
|
||||
"lang": app.storage.lang.Setup[lang],
|
||||
"emailLang": app.storage.lang.Email[emailLang],
|
||||
"language": app.storage.lang.Setup[lang].JSON,
|
||||
"messages": string(msg),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,32 @@
|
||||
all:
|
||||
-mkdir -p out
|
||||
cp index.html ../css/modal.css out/
|
||||
cp ../css/modal.css out/
|
||||
NOTEMPLATE=1 node ../scripts/missing-colors.js index.html out/index.html
|
||||
cp -r node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 out/
|
||||
npx esbuild --bundle ts/main.ts --outfile=out/main.js --minify
|
||||
-rm -r tempts
|
||||
cp -r ts tempts
|
||||
../scripts/dark-variant.sh tempts
|
||||
npx esbuild --bundle tempts/main.ts --outfile=out/main.js --minify
|
||||
npx esbuild --bundle base.css --outfile=out/bundle.css --external:remixicon.css --external:modal.css --minify
|
||||
npx tailwindcss -i out/bundle.css -o out/bundle.css
|
||||
cd out && npx uncss index.html --stylesheets bundle.css > _bundle.css; cd ..
|
||||
mv out/_bundle.css out/bundle.css
|
||||
cd out && npx uncss index.html --stylesheets remixicon.css > _remixicon.css; cd ..
|
||||
mv out/_remixicon.css out/remixicon.css
|
||||
cp ../static/* out/
|
||||
node inject.js
|
||||
|
||||
debug:
|
||||
-mkdir -p out
|
||||
cp index.html out/
|
||||
cp ../css/modal.css out/
|
||||
NOTEMPLATE=1 node ../scripts/missing-colors.js index.html out/index.html
|
||||
cp -r node_modules/remixicon/fonts/remixicon.css node_modules/remixicon/fonts/remixicon.woff2 out/
|
||||
-rm -r tempts
|
||||
cp -r ts tempts
|
||||
../scripts/dark-variant.sh tempts
|
||||
npx esbuild --bundle base.css --outfile=out/bundle.css --external:remixicon.css --minify
|
||||
npx esbuild --bundle ts/main.ts --sourcemap --outfile=out/main.js --minify
|
||||
npx tailwindcss -i out/bundle.css -o out/bundle.css
|
||||
cp ../static/* out/
|
||||
|
||||
monitor:
|
||||
|
||||
@@ -11,7 +11,3 @@ body {
|
||||
background: #AA5CC3;
|
||||
background: linear-gradient(90deg, #AA5CC3 0%, #00A4DC 100%) !important;
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</head>
|
||||
<body class="max-w-full overflow-x-hidden section">
|
||||
<div id="modal-deb" class="modal">
|
||||
<div class="modal-content wide card ~neutral">
|
||||
<div class="relative mx-auto my-[10%] w-4/5 lg:w-2/3 content card">
|
||||
<span class="heading"> Debian/Ubuntu (apt)</span>
|
||||
<div class="mt-1">
|
||||
<pre style="margin: 0; line-height: 125%">curl https://apt.hrfee.dev/hrfee.pubkey.gpg | sudo apt-key add -
|
||||
@@ -38,7 +38,7 @@ sudo apt-get install jfa-go-tray
|
||||
</div>
|
||||
</div>
|
||||
<div id="modal-docker" class="modal">
|
||||
<div class="modal-content wide card ~neutral">
|
||||
<div class="relative mx-auto my-[10%] w-4/5 lg:w-2/3 content card">
|
||||
<span class="heading"> Docker</span>
|
||||
<div class="mt-1">
|
||||
<pre style="margin: 0; line-height: 125%">docker create <span style="color: #BB6622; font-weight: bold">\</span>
|
||||
@@ -61,7 +61,7 @@ sudo apt-get install jfa-go-tray
|
||||
<p class="content">a better way to manage your Jellyfin users.</p>
|
||||
</div>
|
||||
<div class="row col flex center">
|
||||
<ul class="support">
|
||||
<ul class="support list-disc">
|
||||
<li>Send invite links to your users, let them sign up themselves</li>
|
||||
<li>Create setting profiles to restrict permissions of new users</li>
|
||||
<li>Handles password resets without your intervention</li>
|
||||
@@ -74,23 +74,23 @@ sudo apt-get install jfa-go-tray
|
||||
</div>
|
||||
<span class="row col flex center supra">links</span>
|
||||
<div class="row col flex center">
|
||||
<a class="button ~neutral mr-half mt-1 mb-1" href="https://github.com/hrfee/jfa-go">github</a>
|
||||
<a class="button ~urge mt-1 mb-1 mr-half" href="https://wiki.jfa-go.com">wiki/docs</a>
|
||||
<a class="button ~positive mt-1 mb-1 mr-half" href="https://weblate.jfa-go.com">translation</a>
|
||||
<div class="dropdown mr-half" tabindex="0">
|
||||
<a class="button ~neutral mr-2 mt-1 mb-1" href="https://github.com/hrfee/jfa-go">github</a>
|
||||
<a class="button ~urge mt-1 mb-1 mr-2" href="https://wiki.jfa-go.com">wiki/docs</a>
|
||||
<a class="button ~positive mt-1 mb-1 mr-2" href="https://weblate.jfa-go.com">translation</a>
|
||||
<div class="dropdown mr-2" tabindex="0">
|
||||
<a href="https://github.com/sponsors/hrfee" target="_blank" class="button ~info mt-1 mb-1 dropdown-button">
|
||||
<i class="ri-hand-heart-line mr-half"></i>
|
||||
<i class="ri-hand-heart-line mr-2"></i>
|
||||
donate
|
||||
<span class="ml-1 chev"></span>
|
||||
<span class="ml-2 chev"></span>
|
||||
</a>
|
||||
<div class="dropdown-display">
|
||||
<div class="card ~info @low">
|
||||
<a href="https://github.com/sponsors/hrfee" target="_blank" class="button input ~neutral field mb-half lang-link">GitHub</a>
|
||||
<a href="https://ko-fi.com/hrfee" target="_blank" class="button input ~neutral field mb-half lang-link">Ko-fi</a>
|
||||
<div class="card @low">
|
||||
<a href="https://github.com/sponsors/hrfee" target="_blank" class="button input ~neutral field mb-2 lang-link">GitHub</a>
|
||||
<a href="https://ko-fi.com/hrfee" target="_blank" class="button input ~neutral field mb-2 lang-link">Ko-fi</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a class="button ~urge mt-1 mb-1 @low discord" href="https://discord.com/invite/MrtvuQmyhP" target="_blank"><i class="ri-discord-line mr-half"></i>discord</a>
|
||||
<a class="button ~urge mt-1 mb-1 @low discord" href="https://discord.com/invite/MrtvuQmyhP" target="_blank"><i class="ri-discord-line mr-2"></i>discord</a>
|
||||
</div>
|
||||
<p class="row col flex center supra">downloads</p>
|
||||
<p class="row col flex center support">instructions can be found <a target="_blank" href="https://github.com/hrfee/jfa-go#install">here</a></p>
|
||||
@@ -102,19 +102,19 @@ sudo apt-get install jfa-go-tray
|
||||
<div class="mt-1" id="sect-stable">
|
||||
<p class="row center">Usually released once/twice every month, and aren't necessarily super stable.</p>
|
||||
<div class="row col flex center">
|
||||
<a class="button ~info mr-half mb-half lang-link" target="_blank" href="https://github.com/hrfee/jfa-go/releases">windows/mac/linux</a>
|
||||
<a class="button ~info mr-half mb-half lang-link" id="download-docker">docker</a>
|
||||
<a class="button ~info mr-half mb-half lang-link" id="download-deb">debian/ubuntu</a>
|
||||
<a class="button ~info mr-half mb-half lang-link" target="_blank" href="https://aur.archlinux.org/packages/jfa-go">arch (aur)</a>
|
||||
<a class="button ~info mr-half mb-half lang-link" target="_blank" href="https://aur.archlinux.org/packages/jfa-go-bin">arch (aur binary)</a>
|
||||
<a class="button ~info mr-2 mb-2 lang-link" target="_blank" href="https://github.com/hrfee/jfa-go/releases">windows/mac/linux</a>
|
||||
<a class="button ~info mr-2 mb-2 lang-link" id="download-docker">docker</a>
|
||||
<a class="button ~info mr-2 mb-2 lang-link" id="download-deb">debian/ubuntu</a>
|
||||
<a class="button ~info mr-2 mb-2 lang-link" target="_blank" href="https://aur.archlinux.org/packages/jfa-go">arch (aur)</a>
|
||||
<a class="button ~info mr-2 mb-2 lang-link" target="_blank" href="https://aur.archlinux.org/packages/jfa-go-bin">arch (aur binary)</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-1 unfocused" id="sect-unstable">
|
||||
<p class="row center">These are built on every commit, so may include incomplete/broken features. Take care.</p>
|
||||
<div class="row col flex center">
|
||||
<a class="button ~info mr-half mb-half lang-link" id="download-docker-unstable">docker</a>
|
||||
<a class="button ~info mr-half mb-half lang-link" id="download-deb-unstable">debian/ubuntu</a>
|
||||
<a class="button ~info mr-half mb-half lang-link" target="_blank" href="https://aur.archlinux.org/packages/jfa-go-git">arch (aur git)</a>
|
||||
<a class="button ~info mr-2 mb-2 lang-link" id="download-docker-unstable">docker</a>
|
||||
<a class="button ~info mr-2 mb-2 lang-link" id="download-deb-unstable">debian/ubuntu</a>
|
||||
<a class="button ~info mr-2 mb-2 lang-link" target="_blank" href="https://aur.archlinux.org/packages/jfa-go-git">arch (aur git)</a>
|
||||
</div>
|
||||
</div>
|
||||
<section class="section ~neutral banner footer flex-expand middle">
|
||||
|
||||
5
site/inject.js
Normal file
5
site/inject.js
Normal file
@@ -0,0 +1,5 @@
|
||||
let fs = require('fs');
|
||||
|
||||
let content = fs.readFileSync("out/index.html", 'utf8');
|
||||
|
||||
fs.writeFileSync("out/index.html", content.replace('<script src="main.js"></script>', '<script src="main.js"></script>'+process.env.INJECT));
|
||||
1806
site/package-lock.json
generated
1806
site/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,9 +9,10 @@
|
||||
"author": "Harvey Tindall <hrfee@hrfee.dev>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"a17t": "^0.5.1",
|
||||
"a17t": "^0.10.1",
|
||||
"esbuild": "^0.12.12",
|
||||
"remixicon": "^2.5.0",
|
||||
"tailwindcss": "^3.0.10",
|
||||
"uncss": "^0.17.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
26
site/tailwind.config.js
Normal file
26
site/tailwind.config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
let colors = require("tailwindcss/colors")
|
||||
let dark = require("../css/dark");
|
||||
|
||||
module.exports = {
|
||||
content: ["./index.html", "./out/main.js"],
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
neutral: colors.slate,
|
||||
positive: colors.green,
|
||||
urge: colors.violet,
|
||||
warning: colors.yellow,
|
||||
info: colors.blue,
|
||||
critical: colors.red,
|
||||
d_neutral: dark.d_neutral,
|
||||
d_positive: dark.d_positive,
|
||||
d_urge: dark.d_urge,
|
||||
d_warning: dark.d_warning,
|
||||
d_info: dark.d_info,
|
||||
d_critical: dark.d_critical
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [require("a17t")],
|
||||
}
|
||||
@@ -30,6 +30,7 @@ stableButton.onclick = () => {
|
||||
debUnstable.classList.add("unfocused");
|
||||
dockerUnstable.classList.add("unfocused");
|
||||
stableButton.classList.add("@high");
|
||||
stableButton.classList.remove("@low");
|
||||
unstableButton.classList.remove("@high");
|
||||
stableSect.classList.remove("unfocused");
|
||||
unstableSect.classList.add("unfocused");
|
||||
@@ -40,6 +41,7 @@ unstableButton.onclick = () => {
|
||||
debUnstable.classList.remove("unfocused");
|
||||
dockerUnstable.classList.remove("unfocused");
|
||||
unstableButton.classList.add("@high");
|
||||
unstableButton.classList.remove("@low");
|
||||
stableButton.classList.remove("@high");
|
||||
stableSect.classList.add("unfocused");
|
||||
unstableSect.classList.remove("unfocused");
|
||||
|
||||
@@ -24,7 +24,7 @@ export const loadBuilds = () => {
|
||||
for (let buildName in categories) {
|
||||
if (Object.keys(categories[buildName]).length == 1) {
|
||||
const button = document.createElement("a") as HTMLAnchorElement;
|
||||
button.classList.add("button", "~info", "mr-half", "mb-half", "lang-link");
|
||||
button.classList.add("button", "~info", "mr-2", "mb-2", "lang-link");
|
||||
button.target = "_blank";
|
||||
button.textContent = buildName.toLowerCase();
|
||||
button.href = urlBase + categories[buildName][Object.keys(categories[buildName])[0]];
|
||||
@@ -34,16 +34,16 @@ export const loadBuilds = () => {
|
||||
dropdown.tabIndex = 0;
|
||||
dropdown.classList.add("dropdown");
|
||||
let innerHTML = `
|
||||
<span class="button ~info mr-half mb-half lang-link">
|
||||
<span class="button ~info mr-2 mb-2 lang-link">
|
||||
${buildName.toLowerCase()}
|
||||
<span class="ml-half chev"></span>
|
||||
<span class="ml-2 chev"></span>
|
||||
</span>
|
||||
<div class="dropdown-display above">
|
||||
<div class="card ~info @low">
|
||||
<div class="card @low">
|
||||
`;
|
||||
for (let arch in categories[buildName]) {
|
||||
innerHTML += `
|
||||
<a href="${urlBase + categories[buildName][arch]}" target="_blank" class="button input ~neutral field mb-half lang-link">${arch}</a>
|
||||
<a href="${urlBase + categories[buildName][arch]}" target="_blank" class="button input ~neutral field mb-2 lang-link">${arch}</a>
|
||||
`;
|
||||
}
|
||||
innerHTML += `
|
||||
|
||||
14
storage.go
14
storage.go
@@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hrfee/mediabrowser"
|
||||
"github.com/steambap/captcha"
|
||||
)
|
||||
|
||||
type Storage struct {
|
||||
@@ -52,7 +53,9 @@ type DiscordUser struct {
|
||||
|
||||
type EmailAddress struct {
|
||||
Addr string
|
||||
Label string // User Label.
|
||||
Contact bool
|
||||
Admin bool // Whether or not user is jfa-go admin.
|
||||
}
|
||||
|
||||
type customEmails struct {
|
||||
@@ -100,11 +103,12 @@ type Invite struct {
|
||||
UserMinutes int `json:"user-minutes,omitempty"`
|
||||
SendTo string `json:"email"`
|
||||
// Used to be stored as formatted time, now as Unix.
|
||||
UsedBy [][]string `json:"used-by"`
|
||||
Notify map[string]map[string]bool `json:"notify"`
|
||||
Profile string `json:"profile"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Keys []string `json:"keys,omitempty"`
|
||||
UsedBy [][]string `json:"used-by"`
|
||||
Notify map[string]map[string]bool `json:"notify"`
|
||||
Profile string `json:"profile"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Keys []string `json:"keys,omitempty"`
|
||||
Captchas map[string]*captcha.Data // Map of Captcha IDs to answers
|
||||
}
|
||||
|
||||
type Lang struct {
|
||||
|
||||
@@ -6,6 +6,28 @@ module.exports = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
keyframes: {
|
||||
'fade-in': {
|
||||
'0%': {
|
||||
opacity: '0'
|
||||
},
|
||||
'100%': {
|
||||
opacity: '1'
|
||||
}
|
||||
},
|
||||
'fade-out': {
|
||||
'0%': {
|
||||
opacity: '1'
|
||||
},
|
||||
'100%': {
|
||||
opacity: '0'
|
||||
}
|
||||
},
|
||||
},
|
||||
animation: {
|
||||
'fade-in': 'fade-in 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)',
|
||||
'fade-out': 'fade-out 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)'
|
||||
},
|
||||
colors: {
|
||||
neutral: colors.slate,
|
||||
positive: colors.green,
|
||||
|
||||
@@ -88,6 +88,8 @@ window.availableProfiles = window.availableProfiles || [];
|
||||
|
||||
window.modals.matrix = new Modal(document.getElementById("modal-matrix"));
|
||||
|
||||
window.modals.logs = new Modal(document.getElementById("modal-logs"));
|
||||
|
||||
if (window.telegramEnabled) {
|
||||
window.modals.telegram = new Modal(document.getElementById("modal-telegram"));
|
||||
}
|
||||
|
||||
132
ts/form.ts
132
ts/form.ts
@@ -30,6 +30,7 @@ interface formWindow extends Window {
|
||||
userExpiryMinutes: number;
|
||||
userExpiryMessage: string;
|
||||
emailRequired: boolean;
|
||||
captcha: boolean;
|
||||
}
|
||||
|
||||
loadLangSelector("form");
|
||||
@@ -69,8 +70,11 @@ if (window.telegramEnabled) {
|
||||
setTimeout(window.telegramModal.close, 2000);
|
||||
telegramButton.classList.add("unfocused");
|
||||
document.getElementById("contact-via").classList.remove("unfocused");
|
||||
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
||||
const radio = document.getElementById("contact-via-telegram") as HTMLInputElement;
|
||||
radio.parentElement.classList.remove("unfocused");
|
||||
radio.checked = true;
|
||||
validatorFunc();
|
||||
} else if (!modalClosed) {
|
||||
setTimeout(checkVerified, 1500);
|
||||
}
|
||||
@@ -129,8 +133,11 @@ if (window.discordEnabled) {
|
||||
setTimeout(window.discordModal.close, 2000);
|
||||
discordButton.classList.add("unfocused");
|
||||
document.getElementById("contact-via").classList.remove("unfocused");
|
||||
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
||||
const radio = document.getElementById("contact-via-discord") as HTMLInputElement;
|
||||
radio.parentElement.classList.remove("unfocused")
|
||||
radio.checked = true;
|
||||
validatorFunc();
|
||||
} else if (!modalClosed) {
|
||||
setTimeout(checkVerified, 1500);
|
||||
}
|
||||
@@ -187,8 +194,11 @@ if (window.matrixEnabled) {
|
||||
matrixPIN = input.value;
|
||||
matrixButton.classList.add("unfocused");
|
||||
document.getElementById("contact-via").classList.remove("unfocused");
|
||||
const radio = document.getElementById("contact-via-discord") as HTMLInputElement;
|
||||
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
||||
const radio = document.getElementById("contact-via-matrix") as HTMLInputElement;
|
||||
radio.parentElement.classList.remove("unfocused");
|
||||
radio.checked = true;
|
||||
validatorFunc();
|
||||
} else {
|
||||
window.notifications.customError("errorInvalidPIN", window.messages["errorInvalidPIN"]);
|
||||
submitButton.classList.add("~critical");
|
||||
@@ -226,25 +236,85 @@ if (window.userExpiryEnabled) {
|
||||
const form = document.getElementById("form-create") as HTMLFormElement;
|
||||
const submitButton = form.querySelector("input[type=submit]") as HTMLInputElement;
|
||||
const submitSpan = form.querySelector("span.submit") as HTMLSpanElement;
|
||||
const submitText = submitSpan.textContent;
|
||||
let usernameField = document.getElementById("create-username") as HTMLInputElement;
|
||||
const emailField = document.getElementById("create-email") as HTMLInputElement;
|
||||
if (!window.usernameEnabled) { usernameField.parentElement.remove(); usernameField = emailField; }
|
||||
const passwordField = document.getElementById("create-password") as HTMLInputElement;
|
||||
const rePasswordField = document.getElementById("create-reenter-password") as HTMLInputElement;
|
||||
|
||||
if (window.emailRequired) {
|
||||
emailField.addEventListener("keyup", () => {
|
||||
if (emailField.value.includes("@")) {
|
||||
submitButton.disabled = false;
|
||||
submitSpan.removeAttribute("disabled");
|
||||
} else {
|
||||
submitButton.disabled = true;
|
||||
submitSpan.setAttribute("disabled", "");
|
||||
let captchaVerified = false;
|
||||
let captchaID = "";
|
||||
let captchaInput = document.getElementById("captcha-input") as HTMLInputElement;
|
||||
const captchaCheckbox = document.getElementById("captcha-success") as HTMLSpanElement;
|
||||
let prevCaptcha = "";
|
||||
|
||||
function baseValidator(oncomplete: (valid: boolean) => void): void {
|
||||
let captchaChecked = false;
|
||||
let captchaChange = false;
|
||||
if (window.captcha) {
|
||||
captchaChange = captchaInput.value != prevCaptcha;
|
||||
if (captchaChange) {
|
||||
prevCaptcha = captchaInput.value;
|
||||
_post("/captcha/verify/" + window.code + "/" + captchaID + "/" + captchaInput.value, null, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status == 204) {
|
||||
captchaCheckbox.innerHTML = `<i class="ri-check-line"></i>`;
|
||||
captchaCheckbox.classList.add("~positive");
|
||||
captchaCheckbox.classList.remove("~critical");
|
||||
captchaVerified = true;
|
||||
captchaChecked = true;
|
||||
} else {
|
||||
captchaCheckbox.innerHTML = `<i class="ri-close-line"></i>`;
|
||||
captchaCheckbox.classList.add("~critical");
|
||||
captchaCheckbox.classList.remove("~positive");
|
||||
captchaVerified = false;
|
||||
captchaChecked = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
if (window.emailRequired) {
|
||||
if (!emailField.value.includes("@")) {
|
||||
oncomplete(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (window.discordEnabled && window.discordRequired && !discordVerified) {
|
||||
oncomplete(false);
|
||||
return;
|
||||
}
|
||||
if (window.telegramEnabled && window.telegramRequired && !telegramVerified) {
|
||||
oncomplete(false);
|
||||
return;
|
||||
}
|
||||
if (window.matrixEnabled && window.matrixRequired && !matrixVerified) {
|
||||
oncomplete(false);
|
||||
return;
|
||||
}
|
||||
if (window.captcha) {
|
||||
if (!captchaChange) {
|
||||
oncomplete(captchaVerified);
|
||||
return;
|
||||
}
|
||||
while (!captchaChecked) {
|
||||
continue;
|
||||
}
|
||||
oncomplete(captchaVerified);
|
||||
} else {
|
||||
oncomplete(true);
|
||||
}
|
||||
}
|
||||
|
||||
var requirements = initValidator(passwordField, rePasswordField, submitButton, submitSpan)
|
||||
let r = initValidator(passwordField, rePasswordField, submitButton, submitSpan, baseValidator);
|
||||
var requirements = r[0];
|
||||
var validatorFunc = r[1] as () => void;
|
||||
|
||||
if (window.emailRequired) {
|
||||
emailField.addEventListener("keyup", validatorFunc)
|
||||
}
|
||||
|
||||
interface respDTO {
|
||||
response: boolean;
|
||||
@@ -262,10 +332,35 @@ interface sendDTO {
|
||||
discord_contact?: boolean;
|
||||
matrix_pin?: string;
|
||||
matrix_contact?: boolean;
|
||||
captcha_id?: string;
|
||||
captcha_text?: string;
|
||||
}
|
||||
|
||||
const genCaptcha = () => {
|
||||
_get("/captcha/gen/"+window.code, null, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status == 200) {
|
||||
captchaID = req.response["id"];
|
||||
document.getElementById("captcha-img").innerHTML = `
|
||||
<img class="w-100" src="${window.location.toString().substring(0, window.location.toString().lastIndexOf("/invite"))}/captcha/img/${window.code}/${captchaID}"></img>
|
||||
`;
|
||||
captchaInput.value = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (window.captcha) {
|
||||
genCaptcha();
|
||||
(document.getElementById("captcha-regen") as HTMLSpanElement).onclick = genCaptcha;
|
||||
captchaInput.onkeyup = validatorFunc;
|
||||
}
|
||||
|
||||
const create = (event: SubmitEvent) => {
|
||||
event.preventDefault();
|
||||
if (window.captcha && !captchaVerified) {
|
||||
|
||||
}
|
||||
toggleLoader(submitSpan);
|
||||
let send: sendDTO = {
|
||||
code: window.code,
|
||||
@@ -294,6 +389,10 @@ const create = (event: SubmitEvent) => {
|
||||
send.matrix_contact = true;
|
||||
}
|
||||
}
|
||||
if (window.captcha) {
|
||||
send.captcha_id = captchaID;
|
||||
send.captcha_text = captchaInput.value;
|
||||
}
|
||||
_post("/newUser", send, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4) {
|
||||
let vals = req.response as respDTO;
|
||||
@@ -307,9 +406,15 @@ const create = (event: SubmitEvent) => {
|
||||
} else {
|
||||
submitSpan.classList.add("~critical");
|
||||
submitSpan.classList.remove("~urge");
|
||||
if (req.response["error"] as string) {
|
||||
submitSpan.textContent = window.messages[req.response["error"]];
|
||||
} else {
|
||||
submitSpan.textContent = window.messages["errorPassword"];
|
||||
}
|
||||
setTimeout(() => {
|
||||
submitSpan.classList.add("~urge");
|
||||
submitSpan.classList.remove("~critical");
|
||||
submitSpan.textContent = submitText;
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
@@ -322,17 +427,18 @@ const create = (event: SubmitEvent) => {
|
||||
window.confirmationModal.show();
|
||||
return;
|
||||
}
|
||||
const old = submitSpan.textContent;
|
||||
if (req.response["error"] in window.messages) {
|
||||
submitSpan.textContent = window.messages[req.response["error"]];
|
||||
} else {
|
||||
submitSpan.textContent = req.response["error"];
|
||||
}
|
||||
setTimeout(() => { submitSpan.textContent = old; }, 1000);
|
||||
setTimeout(() => { submitSpan.textContent = submitText; }, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
validatorFunc();
|
||||
|
||||
form.onsubmit = create;
|
||||
|
||||
@@ -20,6 +20,8 @@ interface User {
|
||||
discord_id: string;
|
||||
matrix: string;
|
||||
notify_matrix: boolean;
|
||||
label: string;
|
||||
accounts_admin: boolean;
|
||||
}
|
||||
|
||||
interface getPinResponse {
|
||||
@@ -60,6 +62,10 @@ class user implements User {
|
||||
private _lastActive: HTMLTableDataCellElement;
|
||||
private _lastActiveUnix: number;
|
||||
private _notifyDropdown: HTMLDivElement;
|
||||
private _label: HTMLInputElement;
|
||||
private _userLabel: string;
|
||||
private _labelEditButton: HTMLElement;
|
||||
private _accounts_admin: HTMLInputElement
|
||||
id = "";
|
||||
private _selected: boolean;
|
||||
|
||||
@@ -94,6 +100,18 @@ class user implements User {
|
||||
}
|
||||
}
|
||||
|
||||
get accounts_admin(): boolean { return this._accounts_admin.checked; }
|
||||
set accounts_admin(a: boolean) {
|
||||
if (!window.jellyfinLogin) return;
|
||||
this._accounts_admin.checked = a;
|
||||
this._accounts_admin.disabled = (window.jfAllowAll || (a && this.admin && window.jfAdminOnly));
|
||||
if (this._accounts_admin.disabled) {
|
||||
this._accounts_admin.title = window.lang.strings("accessJFASettings");
|
||||
} else {
|
||||
this._accounts_admin.title = "";
|
||||
}
|
||||
}
|
||||
|
||||
get disabled(): boolean { return this._disabled.classList.contains("chip"); }
|
||||
set disabled(state: boolean) {
|
||||
if (state) {
|
||||
@@ -380,14 +398,33 @@ class user implements User {
|
||||
}
|
||||
}
|
||||
|
||||
get label(): string { return this._userLabel; }
|
||||
set label(l: string) {
|
||||
this._userLabel = l ? l : "";
|
||||
this._label.innerHTML = l ? l : "";
|
||||
this._labelEditButton.classList.add("ri-edit-line");
|
||||
this._labelEditButton.classList.remove("ri-check-line");
|
||||
if (!l) {
|
||||
this._label.classList.remove("chip", "~gray");
|
||||
} else {
|
||||
this._label.classList.add("chip", "~gray", "mr-2");
|
||||
}
|
||||
}
|
||||
private _checkEvent = new CustomEvent("accountCheckEvent");
|
||||
private _uncheckEvent = new CustomEvent("accountUncheckEvent");
|
||||
|
||||
constructor(user: User) {
|
||||
this._row = document.createElement("tr") as HTMLTableRowElement;
|
||||
let innerHTML = `
|
||||
<td><input type="checkbox" value=""></td>
|
||||
<td><div class="table-inline"><span class="accounts-username py-2"></span> <span class="accounts-admin"></span> <span class="accounts-disabled"></span></span></td>
|
||||
<td><input type="checkbox" class="accounts-select-user" value=""></td>
|
||||
<td><div class="table-inline"><span class="accounts-username py-2 mr-2"></span><span class="accounts-label-container ml-2"></span> <i class="icon ri-edit-line accounts-label-edit"></i> <span class="accounts-admin"></span> <span class="accounts-disabled"></span></span></div></td>
|
||||
`;
|
||||
if (window.jellyfinLogin) {
|
||||
innerHTML += `
|
||||
<td><div class="table-inline justify-center"><input type="checkbox" class="accounts-access-jfa" value=""></div></td>
|
||||
`;
|
||||
}
|
||||
innerHTML += `
|
||||
<td><div class="table-inline"><i class="icon ri-edit-line accounts-email-edit"></i><span class="accounts-email-container ml-2"></span></div></td>
|
||||
`;
|
||||
if (window.telegramEnabled) {
|
||||
@@ -411,7 +448,9 @@ class user implements User {
|
||||
`;
|
||||
this._row.innerHTML = innerHTML;
|
||||
const emailEditor = `<input type="email" class="input ~neutral @low stealth-input">`;
|
||||
this._check = this._row.querySelector("input[type=checkbox]") as HTMLInputElement;
|
||||
const labelEditor = `<input type="text" class="field ~neutral @low stealth-input">`;
|
||||
this._check = this._row.querySelector("input[type=checkbox].accounts-select-user") as HTMLInputElement;
|
||||
this._accounts_admin = this._row.querySelector("input[type=checkbox].accounts-access-jfa") as HTMLInputElement;
|
||||
this._username = this._row.querySelector(".accounts-username") as HTMLSpanElement;
|
||||
this._admin = this._row.querySelector(".accounts-admin") as HTMLSpanElement;
|
||||
this._disabled = this._row.querySelector(".accounts-disabled") as HTMLSpanElement;
|
||||
@@ -422,11 +461,29 @@ class user implements User {
|
||||
this._matrix = this._row.querySelector(".accounts-matrix") as HTMLTableDataCellElement;
|
||||
this._expiry = this._row.querySelector(".accounts-expiry") as HTMLTableDataCellElement;
|
||||
this._lastActive = this._row.querySelector(".accounts-last-active") as HTMLTableDataCellElement;
|
||||
this._label = this._row.querySelector(".accounts-label-container") as HTMLInputElement;
|
||||
this._labelEditButton = this._row.querySelector(".accounts-label-edit") as HTMLElement;
|
||||
this._check.onchange = () => { this.selected = this._check.checked; }
|
||||
|
||||
if (window.jellyfinLogin) {
|
||||
this._accounts_admin.onchange = () => {
|
||||
this.accounts_admin = this._accounts_admin.checked;
|
||||
let send = {};
|
||||
send[this.id] = this.accounts_admin;
|
||||
_post("/users/accounts-admin", send, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status != 204) {
|
||||
this.accounts_admin = !this.accounts_admin;
|
||||
window.notifications.customError("accountsAdminChanged", window.lang.notif("errorUnknown"));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this._notifyDropdown = this._constructDropdown();
|
||||
|
||||
const toggleStealthInput = () => {
|
||||
const toggleEmailInput = () => {
|
||||
if (this._emailEditButton.classList.contains("ri-edit-line")) {
|
||||
this._email.innerHTML = emailEditor;
|
||||
this._email.querySelector("input").value = this._emailAddress;
|
||||
@@ -438,21 +495,52 @@ class user implements User {
|
||||
this._emailEditButton.classList.toggle("ri-check-line");
|
||||
this._emailEditButton.classList.toggle("ri-edit-line");
|
||||
};
|
||||
const outerClickListener = (event: Event) => {
|
||||
const emailClickListener = (event: Event) => {
|
||||
if (!(event.target instanceof HTMLElement && (this._email.contains(event.target) || this._emailEditButton.contains(event.target)))) {
|
||||
toggleStealthInput();
|
||||
toggleEmailInput();
|
||||
this.email = this.email;
|
||||
document.removeEventListener("click", outerClickListener);
|
||||
document.removeEventListener("click", emailClickListener);
|
||||
}
|
||||
};
|
||||
this._emailEditButton.onclick = () => {
|
||||
if (this._emailEditButton.classList.contains("ri-edit-line")) {
|
||||
document.addEventListener('click', outerClickListener);
|
||||
document.addEventListener('click', emailClickListener);
|
||||
} else {
|
||||
this._updateEmail();
|
||||
document.removeEventListener('click', outerClickListener);
|
||||
document.removeEventListener('click', emailClickListener);
|
||||
}
|
||||
toggleStealthInput();
|
||||
toggleEmailInput();
|
||||
};
|
||||
|
||||
const toggleLabelInput = () => {
|
||||
if (this._labelEditButton.classList.contains("ri-edit-line")) {
|
||||
this._label.innerHTML = labelEditor;
|
||||
const input = this._label.querySelector("input");
|
||||
input.value = this._userLabel;
|
||||
input.placeholder = window.lang.strings("label");
|
||||
this._label.classList.remove("ml-2");
|
||||
this._labelEditButton.classList.add("ri-check-line");
|
||||
this._labelEditButton.classList.remove("ri-edit-line");
|
||||
} else {
|
||||
this._updateLabel();
|
||||
this._email.classList.add("ml-2");
|
||||
}
|
||||
};
|
||||
|
||||
const labelClickListener = (event: Event) => {
|
||||
if (!(event.target instanceof HTMLElement && (this._label.contains(event.target) || this._labelEditButton.contains(event.target)))) {
|
||||
toggleLabelInput();
|
||||
document.removeEventListener("click", labelClickListener);
|
||||
}
|
||||
};
|
||||
|
||||
this._labelEditButton.onclick = () => {
|
||||
if (this._labelEditButton.classList.contains("ri-edit-line")) {
|
||||
document.addEventListener('click', labelClickListener);
|
||||
} else {
|
||||
document.removeEventListener('click', labelClickListener);
|
||||
}
|
||||
toggleLabelInput();
|
||||
};
|
||||
|
||||
this.update(user);
|
||||
@@ -462,6 +550,21 @@ class user implements User {
|
||||
this.last_active = this.last_active;
|
||||
});
|
||||
}
|
||||
|
||||
private _updateLabel = () => {
|
||||
let oldLabel = this.label;
|
||||
this.label = this._label.querySelector("input").value;
|
||||
let send = {};
|
||||
send[this.id] = this.label;
|
||||
_post("/users/labels", send, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4) {
|
||||
if (req.status != 204) {
|
||||
this.label = oldLabel;
|
||||
window.notifications.customError("labelChanged", window.lang.notif("errorUnknown"));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
private _updateEmail = () => {
|
||||
let oldEmail = this.email;
|
||||
@@ -544,6 +647,8 @@ class user implements User {
|
||||
this.notify_matrix = user.notify_matrix;
|
||||
this.notify_email = user.notify_email;
|
||||
this.discord_id = user.discord_id;
|
||||
this.label = user.label;
|
||||
this.accounts_admin = user.accounts_admin;
|
||||
}
|
||||
|
||||
asElement = (): HTMLTableRowElement => { return this._row; }
|
||||
@@ -594,6 +699,9 @@ export class accountsList {
|
||||
private _addUserEmail = this._addUserForm.querySelector("input[type=email]") as HTMLInputElement;
|
||||
private _addUserPassword = this._addUserForm.querySelector("input[type=password]") as HTMLInputElement;
|
||||
|
||||
// Whether the "Extend expiry" is extending or setting an expiry.
|
||||
private _settingExpiry = false;
|
||||
|
||||
private _count = 30;
|
||||
private _populateNumbers = () => {
|
||||
const fieldIDs = ["months", "days", "hours", "minutes"];
|
||||
@@ -731,6 +839,7 @@ export class accountsList {
|
||||
this._announceButton.classList.remove("unfocused");
|
||||
}
|
||||
let anyNonExpiries = list.length == 0 ? true : false;
|
||||
let allNonExpiries = true;
|
||||
let noContactCount = 0;
|
||||
// Only show enable/disable button if all selected have the same state.
|
||||
this._shouldEnable = this._users[list[0]].disabled
|
||||
@@ -740,6 +849,9 @@ export class accountsList {
|
||||
anyNonExpiries = true;
|
||||
this._extendExpiry.classList.add("unfocused");
|
||||
}
|
||||
if (this._users[id].expiry) {
|
||||
allNonExpiries = false;
|
||||
}
|
||||
if (showDisableEnable && this._users[id].disabled != this._shouldEnable) {
|
||||
showDisableEnable = false;
|
||||
this._disableEnable.classList.add("unfocused");
|
||||
@@ -749,8 +861,15 @@ export class accountsList {
|
||||
noContactCount++;
|
||||
}
|
||||
}
|
||||
if (!anyNonExpiries) {
|
||||
this._settingExpiry = false;
|
||||
if (!anyNonExpiries && !allNonExpiries) {
|
||||
this._extendExpiry.classList.remove("unfocused");
|
||||
this._extendExpiry.textContent = window.lang.strings("extendExpiry");
|
||||
}
|
||||
if (allNonExpiries) {
|
||||
this._extendExpiry.classList.remove("unfocused");
|
||||
this._extendExpiry.textContent = window.lang.strings("setExpiry");
|
||||
this._settingExpiry = true;
|
||||
}
|
||||
// Only show "Send PWR" if a maximum of 1 user selected doesn't have a contact method
|
||||
if (noContactCount > 1) {
|
||||
@@ -1078,7 +1197,6 @@ export class accountsList {
|
||||
let manualUser: user;
|
||||
for (let id of list) {
|
||||
let user = this._users[id];
|
||||
console.log(user, user.notify_email, user.notify_matrix, user.notify_discord, user.notify_telegram);
|
||||
if (!user.lastNotifyMethod() && !user.email) {
|
||||
manualUser = user;
|
||||
break;
|
||||
@@ -1213,6 +1331,9 @@ export class accountsList {
|
||||
this._enableExpiryNotify.parentElement.classList.remove("unfocused");
|
||||
this._enableExpiryNotify.checked = false;
|
||||
this._enableExpiryReason.value = "";
|
||||
} else if (this._settingExpiry) {
|
||||
header = window.lang.quantity("setExpiry", list.length);
|
||||
this._enableExpiryNotify.parentElement.classList.add("unfocused");
|
||||
} else {
|
||||
header = window.lang.quantity("extendExpiry", applyList.length);
|
||||
this._enableExpiryNotify.parentElement.classList.add("unfocused");
|
||||
|
||||
@@ -257,7 +257,7 @@ class DOMInvite implements Invite {
|
||||
this._header.appendChild(this._codeArea);
|
||||
this._codeArea.classList.add("inv-codearea");
|
||||
this._codeArea.innerHTML = `
|
||||
<a class="invite-link code font-mono bg-inherit mr-4" href=""></a>
|
||||
<a class="invite-link text-black dark:text-white font-mono bg-inherit mr-4" href=""></a>
|
||||
<span class="button ~info @low" title="${window.lang.strings("copy")}"><i class="ri-file-copy-line"></i></span>
|
||||
`;
|
||||
const copyButton = this._codeArea.querySelector("span.button") as HTMLSpanElement;
|
||||
@@ -427,7 +427,7 @@ export class inviteList implements inviteList {
|
||||
<div class="inv inv-empty">
|
||||
<div class="card dark:~d_neutral @low inv-header flex-expand mt-2">
|
||||
<div class="inv-codearea">
|
||||
<span class="code font-mono bg-inherit">${window.lang.strings("inviteNoInvites")}</span>
|
||||
<span class="text-black dark:text-white font-mono bg-inherit">${window.lang.strings("inviteNoInvites")}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,11 +24,12 @@ export class Modal implements Modal {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
this.modal.classList.add('modal-hiding');
|
||||
this.modal.classList.add('animate-fade-out');
|
||||
this.modal.classList.remove("animate-fade-in");
|
||||
const modal = this.modal;
|
||||
const listenerFunc = () => {
|
||||
modal.classList.remove('modal-shown');
|
||||
modal.classList.remove('modal-hiding');
|
||||
modal.classList.remove('block');
|
||||
modal.classList.remove('animate-fade-out');
|
||||
modal.removeEventListener(window.animationEvent, listenerFunc);
|
||||
document.dispatchEvent(this.closeEvent);
|
||||
};
|
||||
@@ -43,11 +44,11 @@ export class Modal implements Modal {
|
||||
}
|
||||
|
||||
show = () => {
|
||||
this.modal.classList.add('modal-shown');
|
||||
this.modal.classList.add('block', 'animate-fade-in');
|
||||
document.dispatchEvent(this.openEvent);
|
||||
}
|
||||
toggle = () => {
|
||||
if (this.modal.classList.contains('modal-shown')) {
|
||||
if (this.modal.classList.contains('animate-fade-in')) {
|
||||
this.close();
|
||||
} else {
|
||||
this.show();
|
||||
|
||||
@@ -472,7 +472,7 @@ class sectionPanel {
|
||||
this._section.classList.add("settings-section", "unfocused");
|
||||
this._section.innerHTML = `
|
||||
<span class="heading">${s.meta.name}</span>
|
||||
<p class="support lg">${s.meta.description}</p>
|
||||
<p class="support lg my-2">${s.meta.description}</p>
|
||||
`;
|
||||
|
||||
this.update(s);
|
||||
@@ -634,6 +634,13 @@ export class settingsList {
|
||||
}
|
||||
});
|
||||
|
||||
private _showLogs = () => _get("/logs", null, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4 && req.status == 200) {
|
||||
(document.getElementById("log-area") as HTMLPreElement).textContent = req.response["log"] as string;
|
||||
window.modals.logs.show();
|
||||
}
|
||||
});
|
||||
|
||||
constructor() {
|
||||
this._sections = {};
|
||||
this._buttons = {};
|
||||
@@ -645,7 +652,7 @@ export class settingsList {
|
||||
};
|
||||
this._saveButton.onclick = this._save;
|
||||
document.addEventListener("settings-requires-restart", () => { this._needsRestart = true; });
|
||||
|
||||
document.getElementById("settings-logs").onclick = this._showLogs;
|
||||
const advancedEnableToggle = document.getElementById("settings-advanced-enabled") as HTMLInputElement;
|
||||
advancedEnableToggle.onchange = () => {
|
||||
document.dispatchEvent(new CustomEvent("settings-advancedState", { detail: advancedEnableToggle.checked }));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
interface valWindow extends Window {
|
||||
validationStrings: pwValStrings;
|
||||
invalidPassword: string;
|
||||
messages: { [key: string]: string };
|
||||
}
|
||||
|
||||
interface pwValString {
|
||||
@@ -59,7 +60,7 @@ class Requirement {
|
||||
validate = (count: number) => { this.valid = (count >= this._minCount); }
|
||||
}
|
||||
|
||||
export function initValidator(passwordField: HTMLInputElement, rePasswordField: HTMLInputElement, submitButton: HTMLInputElement, submitSpan: HTMLSpanElement): { [category: string]: Requirement } {
|
||||
export function initValidator(passwordField: HTMLInputElement, rePasswordField: HTMLInputElement, submitButton: HTMLInputElement, submitSpan: HTMLSpanElement, validatorFunc?: (oncomplete: (valid: boolean) => void) => void): ({ [category: string]: Requirement }|(() => void))[] {
|
||||
var defaultPwValStrings: pwValStrings = {
|
||||
length: {
|
||||
singular: "Must have at least {n} character",
|
||||
@@ -84,18 +85,30 @@ export function initValidator(passwordField: HTMLInputElement, rePasswordField:
|
||||
}
|
||||
|
||||
const checkPasswords = () => {
|
||||
if (passwordField.value != rePasswordField.value) {
|
||||
rePasswordField.setCustomValidity(window.invalidPassword);
|
||||
submitButton.disabled = true;
|
||||
submitSpan.setAttribute("disabled", "");
|
||||
} else {
|
||||
rePasswordField.setCustomValidity("");
|
||||
submitButton.disabled = false;
|
||||
submitSpan.removeAttribute("disabled");
|
||||
}
|
||||
return passwordField.value == rePasswordField.value;
|
||||
}
|
||||
|
||||
const checkValidity = () => {
|
||||
const pw = checkPasswords();
|
||||
validatorFunc((valid: boolean) => {
|
||||
if (pw && valid) {
|
||||
rePasswordField.setCustomValidity("");
|
||||
submitButton.disabled = false;
|
||||
submitSpan.removeAttribute("disabled");
|
||||
} else if (!pw) {
|
||||
rePasswordField.setCustomValidity(window.invalidPassword);
|
||||
submitButton.disabled = true;
|
||||
submitSpan.setAttribute("disabled", "");
|
||||
} else {
|
||||
rePasswordField.setCustomValidity("");
|
||||
submitButton.disabled = true;
|
||||
submitSpan.setAttribute("disabled", "");
|
||||
}
|
||||
});
|
||||
};
|
||||
rePasswordField.addEventListener("keyup", checkPasswords);
|
||||
passwordField.addEventListener("keyup", checkPasswords);
|
||||
|
||||
rePasswordField.addEventListener("keyup", checkValidity);
|
||||
passwordField.addEventListener("keyup", checkValidity);
|
||||
|
||||
|
||||
// Incredible code right here
|
||||
@@ -150,5 +163,5 @@ export function initValidator(passwordField: HTMLInputElement, rePasswordField:
|
||||
}
|
||||
}
|
||||
}
|
||||
return requirements
|
||||
return [requirements, checkValidity]
|
||||
}
|
||||
|
||||
26
ts/setup.ts
26
ts/setup.ts
@@ -239,6 +239,7 @@ const settings = {
|
||||
"language-admin": new LangSelect("admin", get("ui-language-admin")),
|
||||
"jellyfin_login": new BoolRadios("ui-jellyfin_login", "", false, "ui", "jellyfin_login"),
|
||||
"admin_only": new Checkbox(get("ui-admin_only"), "jellyfin_login", true, "ui"),
|
||||
"allow_all": new Checkbox(get("ui-allow_all"), "jellyfin_login", true, "ui"),
|
||||
"username": new Input(get("ui-username"), "", "", "jellyfin_login", false, "ui"),
|
||||
"password": new Input(get("ui-password"), "", "", "jellyfin_login", false, "ui"),
|
||||
"email": new Input(get("ui-email"), "", "", "jellyfin_login", false, "ui"),
|
||||
@@ -389,6 +390,31 @@ settings["email"]["method"].onchange = emailMethodChange;
|
||||
settings["messages"]["enabled"].onchange = emailMethodChange;
|
||||
emailMethodChange();
|
||||
|
||||
const jellyfinLoginAccessChange = () => {
|
||||
const adminOnly = settings["ui"]["admin_only"].value == "true";
|
||||
const allowAll = settings["ui"]["allow_all"].value == "true";
|
||||
const adminOnlyEl = document.getElementById("ui-admin_only") as HTMLInputElement;
|
||||
const allowAllEls = [document.getElementById("ui-allow_all"), document.getElementById("description-ui-allow_all")];
|
||||
const nextButton = adminOnlyEl.parentElement.parentElement.parentElement.querySelector("span.next") as HTMLSpanElement;
|
||||
if (adminOnly && !allowAll) {
|
||||
(allowAllEls[0] as HTMLInputElement).disabled = true;
|
||||
adminOnlyEl.disabled = false;
|
||||
nextButton.removeAttribute("disabled");
|
||||
} else if (!adminOnly && allowAll) {
|
||||
adminOnlyEl.disabled = true;
|
||||
(allowAllEls[0] as HTMLInputElement).disabled = false;
|
||||
nextButton.removeAttribute("disabled");
|
||||
} else {
|
||||
adminOnlyEl.disabled = false;
|
||||
(allowAllEls[0] as HTMLInputElement).disabled = false;
|
||||
nextButton.setAttribute("disabled", "true")
|
||||
}
|
||||
};
|
||||
|
||||
settings["ui"]["admin_only"].onchange = jellyfinLoginAccessChange;
|
||||
settings["ui"]["allow_all"].onchange = jellyfinLoginAccessChange;
|
||||
jellyfinLoginAccessChange();
|
||||
|
||||
const embyHidePWR = () => {
|
||||
const pwr = document.getElementById("password-resets");
|
||||
const val = settings["jellyfin"]["type"].value;
|
||||
|
||||
@@ -37,6 +37,9 @@ declare interface Window {
|
||||
lang: Lang;
|
||||
langFile: {};
|
||||
updater: updater;
|
||||
jellyfinLogin: boolean;
|
||||
jfAdminOnly: boolean;
|
||||
jfAllowAll: boolean;
|
||||
}
|
||||
|
||||
declare interface Update {
|
||||
@@ -107,6 +110,7 @@ declare interface Modals {
|
||||
discord: Modal;
|
||||
matrix: Modal;
|
||||
sendPWR?: Modal;
|
||||
logs: Modal;
|
||||
}
|
||||
|
||||
interface Invite {
|
||||
|
||||
135
views.go
135
views.go
@@ -10,9 +10,11 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang-jwt/jwt"
|
||||
"github.com/hrfee/mediabrowser"
|
||||
"github.com/steambap/captcha"
|
||||
)
|
||||
|
||||
var css = []string{"bundle.css", "remixicon.css"}
|
||||
var cssVersion string
|
||||
var css = []string{cssVersion + "bundle.css", "remixicon.css"}
|
||||
var cssHeader string
|
||||
|
||||
func (app *appContext) loadCSSHeader() string {
|
||||
@@ -109,6 +111,8 @@ func (app *appContext) AdminPage(gc *gin.Context) {
|
||||
emailEnabled, _ := app.config.Section("invite_emails").Key("enabled").Bool()
|
||||
notificationsEnabled, _ := app.config.Section("notifications").Key("enabled").Bool()
|
||||
ombiEnabled := app.config.Section("ombi").Key("enabled").MustBool(false)
|
||||
jfAdminOnly := app.config.Section("ui").Key("admin_only").MustBool(true)
|
||||
jfAllowAll := app.config.Section("ui").Key("allow_all").MustBool(false)
|
||||
var license string
|
||||
l, err := fs.ReadFile(localFS, "LICENSE")
|
||||
if err != nil {
|
||||
@@ -119,6 +123,7 @@ func (app *appContext) AdminPage(gc *gin.Context) {
|
||||
gcHTML(gc, http.StatusOK, "admin.html", gin.H{
|
||||
"urlBase": app.getURLBase(gc),
|
||||
"cssClass": app.cssClass,
|
||||
"cssVersion": cssVersion,
|
||||
"contactMessage": "",
|
||||
"emailEnabled": emailEnabled,
|
||||
"telegramEnabled": telegramEnabled,
|
||||
@@ -135,6 +140,9 @@ func (app *appContext) AdminPage(gc *gin.Context) {
|
||||
"language": app.storage.lang.Admin[lang].JSON,
|
||||
"langName": lang,
|
||||
"license": license,
|
||||
"jellyfinLogin": app.jellyfinLogin,
|
||||
"jfAdminOnly": jfAdminOnly,
|
||||
"jfAllowAll": jfAllowAll,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -151,6 +159,7 @@ func (app *appContext) ResetPassword(gc *gin.Context) {
|
||||
data := gin.H{
|
||||
"urlBase": app.getURLBase(gc),
|
||||
"cssClass": app.cssClass,
|
||||
"cssVersion": cssVersion,
|
||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||
"strings": app.storage.lang.PasswordReset[lang].Strings,
|
||||
"success": false,
|
||||
@@ -245,6 +254,123 @@ func (app *appContext) ResetPassword(gc *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// @Summary returns the captcha image corresponding to the given ID.
|
||||
// @Param code path string true "invite code"
|
||||
// @Param captchaID path string true "captcha ID"
|
||||
// @Tags Other
|
||||
// @Router /captcha/img/{code}/{captchaID} [get]
|
||||
func (app *appContext) GetCaptcha(gc *gin.Context) {
|
||||
code := gc.Param("invCode")
|
||||
captchaID := gc.Param("captchaID")
|
||||
inv, ok := app.storage.invites[code]
|
||||
if !ok {
|
||||
gcHTML(gc, 404, "invalidCode.html", gin.H{
|
||||
"cssClass": app.cssClass,
|
||||
"cssVersion": cssVersion,
|
||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||
})
|
||||
}
|
||||
var capt *captcha.Data
|
||||
if inv.Captchas != nil {
|
||||
capt = inv.Captchas[captchaID]
|
||||
}
|
||||
if capt == nil {
|
||||
respondBool(400, false, gc)
|
||||
return
|
||||
}
|
||||
if err := capt.WriteImage(gc.Writer); err != nil {
|
||||
app.err.Printf("Failed to write CAPTCHA image: %v", err)
|
||||
respondBool(500, false, gc)
|
||||
return
|
||||
}
|
||||
gc.Status(200)
|
||||
return
|
||||
}
|
||||
|
||||
// @Summary Generates a new captcha and returns it's ID. This can then be included in a request to /captcha/img/{id} to get an image.
|
||||
// @Produce json
|
||||
// @Param code path string true "invite code"
|
||||
// @Success 200 {object} genCaptchaDTO
|
||||
// @Router /captcha/gen/{code} [get]
|
||||
// @Security Bearer
|
||||
// @tags Users
|
||||
func (app *appContext) GenCaptcha(gc *gin.Context) {
|
||||
code := gc.Param("invCode")
|
||||
inv, ok := app.storage.invites[code]
|
||||
if !ok {
|
||||
gcHTML(gc, 404, "invalidCode.html", gin.H{
|
||||
"cssClass": app.cssClass,
|
||||
"cssVersion": cssVersion,
|
||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||
})
|
||||
}
|
||||
capt, err := captcha.New(300, 100)
|
||||
if err != nil {
|
||||
app.err.Printf("Failed to generate captcha: %v", err)
|
||||
respondBool(500, false, gc)
|
||||
return
|
||||
}
|
||||
if inv.Captchas == nil {
|
||||
inv.Captchas = map[string]*captcha.Data{}
|
||||
}
|
||||
captchaID := genAuthToken()
|
||||
inv.Captchas[captchaID] = capt
|
||||
app.storage.invites[code] = inv
|
||||
app.storage.storeInvites()
|
||||
gc.JSON(200, genCaptchaDTO{captchaID})
|
||||
return
|
||||
}
|
||||
|
||||
func (app *appContext) verifyCaptcha(code, id, text string) bool {
|
||||
inv, ok := app.storage.invites[code]
|
||||
if !ok || inv.Captchas == nil {
|
||||
app.debug.Printf("Couldn't find invite \"%s\"", code)
|
||||
return false
|
||||
}
|
||||
c, ok := inv.Captchas[id]
|
||||
if !ok {
|
||||
app.debug.Printf("Couldn't find Captcha \"%s\"", id)
|
||||
return false
|
||||
}
|
||||
return strings.ToLower(c.Text) == strings.ToLower(text)
|
||||
}
|
||||
|
||||
// @Summary returns 204 if the given Captcha contents is correct for the corresponding captcha ID and invite code.
|
||||
// @Param code path string true "invite code"
|
||||
// @Param captchaID path string true "captcha ID"
|
||||
// @Param text path string true "Captcha text"
|
||||
// @Success 204
|
||||
// @Tags Other
|
||||
// @Router /captcha/verify/{code}/{captchaID}/{text} [get]
|
||||
func (app *appContext) VerifyCaptcha(gc *gin.Context) {
|
||||
code := gc.Param("invCode")
|
||||
captchaID := gc.Param("captchaID")
|
||||
text := gc.Param("text")
|
||||
inv, ok := app.storage.invites[code]
|
||||
if !ok {
|
||||
gcHTML(gc, 404, "invalidCode.html", gin.H{
|
||||
"cssClass": app.cssClass,
|
||||
"cssVersion": cssVersion,
|
||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||
})
|
||||
return
|
||||
}
|
||||
var capt *captcha.Data
|
||||
if inv.Captchas != nil {
|
||||
capt = inv.Captchas[captchaID]
|
||||
}
|
||||
if capt == nil {
|
||||
respondBool(400, false, gc)
|
||||
return
|
||||
}
|
||||
if strings.ToLower(capt.Text) != strings.ToLower(text) {
|
||||
respondBool(400, false, gc)
|
||||
return
|
||||
}
|
||||
respondBool(204, true, gc)
|
||||
return
|
||||
}
|
||||
|
||||
func (app *appContext) InviteProxy(gc *gin.Context) {
|
||||
app.pushResources(gc, false)
|
||||
code := gc.Param("invCode")
|
||||
@@ -255,6 +381,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
||||
if !ok {
|
||||
gcHTML(gc, 404, "invalidCode.html", gin.H{
|
||||
"cssClass": app.cssClass,
|
||||
"cssVersion": cssVersion,
|
||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||
})
|
||||
return
|
||||
@@ -272,6 +399,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
||||
fail := func() {
|
||||
gcHTML(gc, 404, "404.html", gin.H{
|
||||
"cssClass": app.cssClass,
|
||||
"cssVersion": cssVersion,
|
||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||
})
|
||||
}
|
||||
@@ -334,6 +462,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
||||
data := gin.H{
|
||||
"urlBase": app.getURLBase(gc),
|
||||
"cssClass": app.cssClass,
|
||||
"cssVersion": cssVersion,
|
||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||
"helpMessage": app.config.Section("ui").Key("help_message").String(),
|
||||
"successMessage": app.config.Section("ui").Key("success_message").String(),
|
||||
@@ -359,6 +488,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
||||
"discordEnabled": discord,
|
||||
"matrixEnabled": matrix,
|
||||
"emailRequired": app.config.Section("email").Key("required").MustBool(false),
|
||||
"captcha": app.config.Section("captcha").Key("enabled").MustBool(false),
|
||||
}
|
||||
if telegram {
|
||||
data["telegramPIN"] = app.telegram.NewAuthToken()
|
||||
@@ -375,7 +505,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
||||
data["discordUsername"] = app.discord.username
|
||||
data["discordRequired"] = app.config.Section("discord").Key("required").MustBool(false)
|
||||
data["discordSendPINMessage"] = template.HTML(app.storage.lang.Form[lang].Strings.template("sendPINDiscord", tmpl{
|
||||
"command": `<code class="code">` + app.config.Section("discord").Key("start_command").MustString("!start") + `</code>`,
|
||||
"command": `<span class="text-black dark:text-white font-mono">/` + app.config.Section("discord").Key("start_command").MustString("start") + `</span>`,
|
||||
"server_channel": app.discord.serverChannelName,
|
||||
}))
|
||||
data["discordServerName"] = app.discord.serverName
|
||||
@@ -393,6 +523,7 @@ func (app *appContext) NoRouteHandler(gc *gin.Context) {
|
||||
app.pushResources(gc, false)
|
||||
gcHTML(gc, 404, "404.html", gin.H{
|
||||
"cssClass": app.cssClass,
|
||||
"cssVersion": cssVersion,
|
||||
"contactMessage": app.config.Section("ui").Key("contact_message").String(),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user