Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aeb0f37e20 | ||
|
|
59a0daa293 | ||
|
|
c716d126eb | ||
|
|
5dc210c000 | ||
|
|
3bb3fdb956 | ||
|
|
b96a4a63c0 | ||
|
|
3d54b2bd90 | ||
|
|
95d43a344c | ||
|
|
1077d5cd6b | ||
|
|
57cc174b3d | ||
|
|
cf61baa273 | ||
|
|
2d5cd2d1d3 | ||
|
|
9472aad877 | ||
|
|
dd0f3ef144 | ||
|
|
44e492160b | ||
|
|
0137b03887 | ||
|
|
92c9b134c3 | ||
|
|
1737702c7c | ||
|
|
ece52ecf7c | ||
|
|
a7d6a72718 | ||
|
|
3fa9286238 | ||
|
|
ad5ff4cfe0 | ||
|
|
9aee1ebd2a |
No files matched your search
@@ -6,3 +6,5 @@ node_modules/
|
|||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
+1
-1
@@ -15,7 +15,7 @@ install:
|
|||||||
- go get github.com/tsenart/deadcode
|
- go get github.com/tsenart/deadcode
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- gometalinter --disable-all -E vet -E gofmt -E misspell -E ineffassign -E goimports -E deadcode --exclude="rice-box.go" --tests ./...
|
- gometalinter --disable-all -E gofmt -E misspell -E ineffassign -E goimports -E deadcode --exclude="rice-box.go" --tests ./...
|
||||||
- go test ./... -timeout 30s
|
- go test ./... -timeout 30s
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
|
|||||||
@@ -196,6 +196,10 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
paste (event) {
|
paste (event) {
|
||||||
|
if (event.target.tagName.toLowerCase() === 'input') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
let items = []
|
let items = []
|
||||||
|
|||||||
@@ -119,9 +119,21 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.shiftKey && this.selected.length === 1) {
|
if (event.shiftKey && this.selected.length === 1) {
|
||||||
let fi = (this.index > this.selected[0]) ? this.selected[0] : this.index
|
let fi = 0
|
||||||
let la = (this.index > this.selected[0]) ? this.index : this.selected[0]
|
let la = 0
|
||||||
for (; fi <= la; fi++) this.addSelected(fi)
|
|
||||||
|
if (this.index > this.selected[0]) {
|
||||||
|
fi = this.selected[0] + 1
|
||||||
|
la = this.index
|
||||||
|
} else {
|
||||||
|
fi = this.index
|
||||||
|
la = this.selected[0] - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; fi <= la; fi++) {
|
||||||
|
this.addSelected(fi)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
||||||
<button class="flat"
|
<button class="flat"
|
||||||
@click="copy"
|
@click="copy"
|
||||||
|
:disabled="$route.path === dest"
|
||||||
:aria-label="$t('buttons.copy')"
|
:aria-label="$t('buttons.copy')"
|
||||||
:title="$t('buttons.copy')">{{ $t('buttons.copy') }}</button>
|
:title="$t('buttons.copy')">{{ $t('buttons.copy') }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
||||||
<button class="flat"
|
<button class="flat"
|
||||||
@click="move"
|
@click="move"
|
||||||
|
:disabled="$route.path === dest"
|
||||||
:aria-label="$t('buttons.move')"
|
:aria-label="$t('buttons.move')"
|
||||||
:title="$t('buttons.move')">{{ $t('buttons.move') }}</button>
|
:title="$t('buttons.move')">{{ $t('buttons.move') }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -112,6 +112,11 @@ button.flat.cancel {
|
|||||||
color: #ccc;
|
color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.flat[disabled] {
|
||||||
|
color: #ccc;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
.mobile-only {
|
.mobile-only {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,39 @@ import zhTW from './zh-tw.yaml'
|
|||||||
|
|
||||||
Vue.use(VueI18n)
|
Vue.use(VueI18n)
|
||||||
|
|
||||||
|
export function detectLocale () {
|
||||||
|
let locale = (navigator.language || navigator.browserLangugae).toLowerCase()
|
||||||
|
switch (true) {
|
||||||
|
case /^en.*/i.test(locale):
|
||||||
|
locale = 'en'
|
||||||
|
break
|
||||||
|
case /^fr.*/i.test(locale):
|
||||||
|
locale = 'fr'
|
||||||
|
break
|
||||||
|
case /^pt.*/i.test(locale):
|
||||||
|
locale = 'pt'
|
||||||
|
break
|
||||||
|
case /^ja.*/i.test(locale):
|
||||||
|
locale = 'ja'
|
||||||
|
break
|
||||||
|
case /^zh-CN/i.test(locale):
|
||||||
|
locale = 'zh-cn'
|
||||||
|
break
|
||||||
|
case /^zh-TW/i.test(locale):
|
||||||
|
locale = 'zh-tw'
|
||||||
|
break
|
||||||
|
case /^zh.*/i.test(locale):
|
||||||
|
locale = 'zh-cn'
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
locale = 'en'
|
||||||
|
}
|
||||||
|
|
||||||
|
return locale
|
||||||
|
}
|
||||||
|
|
||||||
const i18n = new VueI18n({
|
const i18n = new VueI18n({
|
||||||
locale: 'en',
|
locale: detectLocale(),
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en',
|
||||||
messages: {
|
messages: {
|
||||||
'en': en,
|
'en': en,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import ProfileSettings from '@/views/settings/Profile'
|
|||||||
import Error403 from '@/views/errors/403'
|
import Error403 from '@/views/errors/403'
|
||||||
import Error404 from '@/views/errors/404'
|
import Error404 from '@/views/errors/404'
|
||||||
import Error500 from '@/views/errors/500'
|
import Error500 from '@/views/errors/500'
|
||||||
import auth from '@/utils/auth.js'
|
import auth from '@/utils/auth'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
|
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
@@ -54,6 +54,9 @@ const router = new Router({
|
|||||||
redirect: {
|
redirect: {
|
||||||
path: '/settings/profile'
|
path: '/settings/profile'
|
||||||
},
|
},
|
||||||
|
meta: {
|
||||||
|
disableOnNoAuth: true
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '/settings/profile',
|
path: '/settings/profile',
|
||||||
@@ -127,16 +130,17 @@ router.beforeEach((to, from, next) => {
|
|||||||
auth.loggedIn()
|
auth.loggedIn()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (to.matched.some(record => record.meta.requiresAdmin)) {
|
if (to.matched.some(record => record.meta.requiresAdmin)) {
|
||||||
if (store.state.user.admin) {
|
if (!store.state.user.admin) {
|
||||||
next()
|
next({ path: '/403' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
next({
|
if (to.matched.some(record => record.meta.disableOnNoAuth)) {
|
||||||
path: '/403'
|
if (store.state.noAuth) {
|
||||||
})
|
next({ path: '/403' })
|
||||||
|
return
|
||||||
return
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import i18n from '@/i18n'
|
import * as i18n from '@/i18n'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
@@ -27,8 +27,14 @@ const mutations = {
|
|||||||
setLoading: (state, value) => { state.loading = value },
|
setLoading: (state, value) => { state.loading = value },
|
||||||
setReload: (state, value) => { state.reload = value },
|
setReload: (state, value) => { state.reload = value },
|
||||||
setUser: (state, value) => {
|
setUser: (state, value) => {
|
||||||
moment.locale(value.locale)
|
let locale = value.locale
|
||||||
i18n.locale = value.locale
|
|
||||||
|
if (locale === '') {
|
||||||
|
locale = i18n.detectLocale()
|
||||||
|
}
|
||||||
|
|
||||||
|
moment.locale(locale)
|
||||||
|
i18n.default.locale = locale
|
||||||
state.user = value
|
state.user = value
|
||||||
},
|
},
|
||||||
setCSS: (state, value) => (state.css = value),
|
setCSS: (state, value) => (state.css = value),
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
scroll (event) {
|
scroll (event) {
|
||||||
if (this.req.kind !== 'listing' || this.$store.state.req.display === 'mosaic') return
|
if (this.req.kind !== 'listing' || this.$store.state.user.viewMode === 'mosaic') return
|
||||||
|
|
||||||
let top = 112 - window.scrollY
|
let top = 112 - window.scrollY
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,21 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
|
<p>
|
||||||
|
<label for="username">{{ $t('settings.username') }}</label>
|
||||||
|
<input type="text" v-model="username" id="username">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="password">{{ $t('settings.password') }}</label>
|
||||||
|
<input type="password" :placeholder="passwordPlaceholder" v-model="password" id="password">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="scope">{{ $t('settings.scope') }}</label>
|
||||||
|
<input type="text" v-model="filesystem" id="scope">
|
||||||
|
</p>
|
||||||
|
|
||||||
<p><label for="username">{{ $t('settings.username') }}</label><input type="text" v-model="username" id="username"></p>
|
|
||||||
<p><label for="password">{{ $t('settings.password') }}</label><input type="password" :placeholder="passwordPlaceholder" v-model="password" id="password"></p>
|
|
||||||
<p><label for="scope">{{ $t('settings.scope') }}</label><input type="text" v-model="filesystem" id="scope"></p>
|
|
||||||
<p>
|
<p>
|
||||||
<label for="locale">{{ $t('settings.language') }}</label>
|
<label for="locale">{{ $t('settings.language') }}</label>
|
||||||
<languages id="locale" :selected.sync="locale"></languages>
|
<languages id="locale" :selected.sync="locale"></languages>
|
||||||
@@ -91,6 +102,7 @@ export default {
|
|||||||
components: { Languages },
|
components: { Languages },
|
||||||
data: () => {
|
data: () => {
|
||||||
return {
|
return {
|
||||||
|
originalUser: null,
|
||||||
id: 0,
|
id: 0,
|
||||||
admin: false,
|
admin: false,
|
||||||
allowNew: false,
|
allowNew: false,
|
||||||
@@ -141,6 +153,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUser(user).then(user => {
|
getUser(user).then(user => {
|
||||||
|
this.originalUser = user
|
||||||
this.id = user.ID
|
this.id = user.ID
|
||||||
this.admin = user.admin
|
this.admin = user.admin
|
||||||
this.allowCommands = user.allowCommands
|
this.allowCommands = user.allowCommands
|
||||||
@@ -242,23 +255,21 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
parseForm () {
|
parseForm () {
|
||||||
let user = {
|
let user = this.originalUser
|
||||||
ID: this.id,
|
user.username = this.username
|
||||||
username: this.username,
|
user.password = this.password
|
||||||
password: this.password,
|
user.lockPassword = this.lockPassword
|
||||||
lockPassword: this.lockPassword,
|
user.filesystem = this.filesystem
|
||||||
filesystem: this.filesystem,
|
user.admin = this.admin
|
||||||
admin: this.admin,
|
user.allowCommands = this.allowCommands
|
||||||
allowCommands: this.allowCommands,
|
user.allowNew = this.allowNew
|
||||||
allowNew: this.allowNew,
|
user.allowEdit = this.allowEdit
|
||||||
allowEdit: this.allowEdit,
|
user.allowPublish = this.allowPublish
|
||||||
allowPublish: this.allowPublish,
|
user.permissions = this.permissions
|
||||||
permissions: this.permissions,
|
user.css = this.css
|
||||||
css: this.css,
|
user.locale = this.locale
|
||||||
locale: this.locale,
|
user.commands = this.commands.split(' ')
|
||||||
commands: this.commands.split(' '),
|
user.rules = []
|
||||||
rules: []
|
|
||||||
}
|
|
||||||
|
|
||||||
let rules = this.rules.split('\n')
|
let rules = this.rules.split('\n')
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
u.ViewMode = c.Val()
|
u.ViewMode = c.Val()
|
||||||
if u.ViewMode != "mosaic" && u.ViewMode != "list" {
|
if u.ViewMode != filemanager.MosaicViewMode && u.ViewMode != filemanager.ListViewMode {
|
||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
}
|
}
|
||||||
case "recaptcha_key":
|
case "recaptcha_key":
|
||||||
@@ -207,7 +207,7 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro
|
|||||||
sha := hex.EncodeToString(hasher.Sum(nil))
|
sha := hex.EncodeToString(hasher.Sum(nil))
|
||||||
database = filepath.Join(path, sha+".db")
|
database = filepath.Join(path, sha+".db")
|
||||||
|
|
||||||
fmt.Println("[WARNING] A database is going to be created for your File Manager instace at " + database +
|
fmt.Println("[WARNING] A database is going to be created for your File Manager instance at " + database +
|
||||||
". It is highly recommended that you set the 'database' option to '" + sha + ".db'\n")
|
". It is highly recommended that you set the 'database' option to '" + sha + ".db'\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/asdine/storm"
|
"github.com/asdine/storm"
|
||||||
|
|
||||||
lumberjack "gopkg.in/natefinch/lumberjack.v2"
|
"gopkg.in/natefinch/lumberjack.v2"
|
||||||
|
|
||||||
"github.com/hacdias/filemanager"
|
"github.com/hacdias/filemanager"
|
||||||
"github.com/hacdias/filemanager/bolt"
|
"github.com/hacdias/filemanager/bolt"
|
||||||
@@ -64,7 +64,7 @@ func init() {
|
|||||||
flag.BoolVar(&allowPublish, "allow-publish", true, "Default allow publish option for new users")
|
flag.BoolVar(&allowPublish, "allow-publish", true, "Default allow publish option for new users")
|
||||||
flag.BoolVar(&allowNew, "allow-new", true, "Default allow new option for new users")
|
flag.BoolVar(&allowNew, "allow-new", true, "Default allow new option for new users")
|
||||||
flag.BoolVar(&noAuth, "no-auth", false, "Disables authentication")
|
flag.BoolVar(&noAuth, "no-auth", false, "Disables authentication")
|
||||||
flag.StringVar(&locale, "locale", "en", "Default locale for new users")
|
flag.StringVar(&locale, "locale", "", "Default locale for new users, set it empty to enable auto detect from browser")
|
||||||
flag.StringVar(&staticg, "staticgen", "", "Static Generator you want to enable")
|
flag.StringVar(&staticg, "staticgen", "", "Static Generator you want to enable")
|
||||||
flag.BoolVarP(&showVer, "version", "v", false, "Show version")
|
flag.BoolVarP(&showVer, "version", "v", false, "Show version")
|
||||||
}
|
}
|
||||||
@@ -81,11 +81,11 @@ func setupViper() {
|
|||||||
viper.SetDefault("AllowNew", true)
|
viper.SetDefault("AllowNew", true)
|
||||||
viper.SetDefault("AllowPublish", true)
|
viper.SetDefault("AllowPublish", true)
|
||||||
viper.SetDefault("StaticGen", "")
|
viper.SetDefault("StaticGen", "")
|
||||||
viper.SetDefault("Locale", "en")
|
viper.SetDefault("Locale", "")
|
||||||
viper.SetDefault("NoAuth", false)
|
viper.SetDefault("NoAuth", false)
|
||||||
viper.SetDefault("BaseURL", "")
|
viper.SetDefault("BaseURL", "")
|
||||||
viper.SetDefault("PrefixURL", "")
|
viper.SetDefault("PrefixURL", "")
|
||||||
viper.SetDefault("ViewMode", "mosaic")
|
viper.SetDefault("ViewMode", filemanager.MosaicViewMode)
|
||||||
viper.SetDefault("ReCaptchaKey", "")
|
viper.SetDefault("ReCaptchaKey", "")
|
||||||
viper.SetDefault("ReCaptchaSecret", "")
|
viper.SetDefault("ReCaptchaSecret", "")
|
||||||
|
|
||||||
|
|||||||
@@ -418,6 +418,7 @@ var textExtensions = [...]string{
|
|||||||
".sh", ".bash", ".ps1", ".bat", ".cmd",
|
".sh", ".bash", ".ps1", ".bat", ".cmd",
|
||||||
".php", ".pl", ".py",
|
".php", ".pl", ".py",
|
||||||
"Caddyfile",
|
"Caddyfile",
|
||||||
|
".htaccess",
|
||||||
".c", ".cc", ".h", ".hh", ".cpp", ".hpp", ".f90",
|
".c", ".cc", ".h", ".hh", ".cpp", ".hpp", ".f90",
|
||||||
".f", ".bas", ".d", ".ada", ".nim", ".cr", ".java", ".cs", ".vala", ".vapi",
|
".f", ".bas", ".d", ".ada", ".nim", ".cr", ".java", ".cs", ".vala", ".vapi",
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-6
@@ -15,14 +15,20 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
|
||||||
rice "github.com/GeertJohan/go.rice"
|
"github.com/GeertJohan/go.rice"
|
||||||
"github.com/hacdias/fileutils"
|
"github.com/hacdias/fileutils"
|
||||||
"github.com/mholt/caddy"
|
"github.com/mholt/caddy"
|
||||||
"github.com/robfig/cron"
|
"github.com/robfig/cron"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version is the current File Manager version.
|
// Version is the current File Manager version.
|
||||||
const Version = "1.3.5"
|
const (
|
||||||
|
// Version is the current File Manager version.
|
||||||
|
Version = "1.3.9"
|
||||||
|
|
||||||
|
ListViewMode = "list"
|
||||||
|
MosaicViewMode = "mosaic"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrExist = errors.New("the resource already exists")
|
ErrExist = errors.New("the resource already exists")
|
||||||
@@ -33,7 +39,7 @@ var (
|
|||||||
ErrEmptyScope = errors.New("scope is empty")
|
ErrEmptyScope = errors.New("scope is empty")
|
||||||
ErrWrongDataType = errors.New("wrong data type")
|
ErrWrongDataType = errors.New("wrong data type")
|
||||||
ErrInvalidUpdateField = errors.New("invalid field to update")
|
ErrInvalidUpdateField = errors.New("invalid field to update")
|
||||||
ErrInvalidOption = errors.New("Invalid option")
|
ErrInvalidOption = errors.New("invalid option")
|
||||||
)
|
)
|
||||||
|
|
||||||
// FileManager is a file manager instance. It should be creating using the
|
// FileManager is a file manager instance. It should be creating using the
|
||||||
@@ -207,8 +213,8 @@ func (m *FileManager) Setup() error {
|
|||||||
|
|
||||||
// TODO: remove this after 1.5
|
// TODO: remove this after 1.5
|
||||||
for _, user := range users {
|
for _, user := range users {
|
||||||
if user.ViewMode != "list" && user.ViewMode != "mosaic" {
|
if user.ViewMode != ListViewMode && user.ViewMode != MosaicViewMode {
|
||||||
user.ViewMode = "list"
|
user.ViewMode = ListViewMode
|
||||||
m.Store.Users.Update(user, "ViewMode")
|
m.Store.Users.Update(user, "ViewMode")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,7 +362,7 @@ var DefaultUser = User{
|
|||||||
Rules: []*Rule{},
|
Rules: []*Rule{},
|
||||||
CSS: "",
|
CSS: "",
|
||||||
Admin: true,
|
Admin: true,
|
||||||
Locale: "en",
|
Locale: "",
|
||||||
Scope: ".",
|
Scope: ".",
|
||||||
FileSystem: fileutils.Dir("."),
|
FileSystem: fileutils.Dir("."),
|
||||||
ViewMode: "mosaic",
|
ViewMode: "mosaic",
|
||||||
|
|||||||
+11
-10
@@ -1,7 +1,6 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -9,27 +8,28 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
jwt "github.com/dgrijalva/jwt-go"
|
"github.com/dgrijalva/jwt-go"
|
||||||
"github.com/dgrijalva/jwt-go/request"
|
"github.com/dgrijalva/jwt-go/request"
|
||||||
fm "github.com/hacdias/filemanager"
|
fm "github.com/hacdias/filemanager"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const reCaptchaAPI = "https://www.google.com/recaptcha/api/siteverify"
|
||||||
|
|
||||||
type cred struct {
|
type cred struct {
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Recaptcha string `json:"recaptcha"`
|
ReCaptcha string `json:"recaptcha"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// recaptcha checks the recaptcha code.
|
// reCaptcha checks the reCaptcha code.
|
||||||
func recaptcha(secret string, response string) (bool, error) {
|
func reCaptcha(secret string, response string) (bool, error) {
|
||||||
api := "https://www.google.com/recaptcha/api/siteverify"
|
|
||||||
|
|
||||||
body := url.Values{}
|
body := url.Values{}
|
||||||
body.Set("secret", secret)
|
body.Set("secret", secret)
|
||||||
body.Add("response", response)
|
body.Add("response", response)
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
resp, err := client.Post(api, "application/x-www-form-urlencoded", bytes.NewBufferString(body.Encode()))
|
|
||||||
|
resp, err := client.Post(reCaptchaAPI, "application/x-www-form-urlencoded", strings.NewReader(body.Encode()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ func recaptcha(secret string, response string) (bool, error) {
|
|||||||
return data.Success, nil
|
return data.Success, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// authHandler proccesses the authentication for the user.
|
// authHandler processes the authentication for the user.
|
||||||
func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
// NoAuth instances shouldn't call this method.
|
// NoAuth instances shouldn't call this method.
|
||||||
if c.NoAuth {
|
if c.NoAuth {
|
||||||
@@ -73,7 +73,7 @@ func authHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, er
|
|||||||
|
|
||||||
// If ReCaptcha is enabled, check the code.
|
// If ReCaptcha is enabled, check the code.
|
||||||
if len(c.ReCaptchaSecret) > 0 {
|
if len(c.ReCaptchaSecret) > 0 {
|
||||||
ok, err := recaptcha(c.ReCaptchaSecret, cred.Recaptcha)
|
ok, err := reCaptcha(c.ReCaptchaSecret, cred.ReCaptcha)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return http.StatusForbidden, err
|
return http.StatusForbidden, err
|
||||||
@@ -179,6 +179,7 @@ func validateAuth(c *fm.Context, r *http.Request) (bool, *fm.User) {
|
|||||||
keyFunc := func(token *jwt.Token) (interface{}, error) {
|
keyFunc := func(token *jwt.Token) (interface{}, error) {
|
||||||
return c.Key, nil
|
return c.Key, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var claims claims
|
var claims claims
|
||||||
token, err := request.ParseFromRequestWithClaims(r,
|
token, err := request.ParseFromRequestWithClaims(r,
|
||||||
extractor{},
|
extractor{},
|
||||||
|
|||||||
+13
-10
@@ -17,21 +17,13 @@ import (
|
|||||||
// downloadHandler creates an archive in one of the supported formats (zip, tar,
|
// downloadHandler creates an archive in one of the supported formats (zip, tar,
|
||||||
// tar.gz or tar.bz2) and sends it to be downloaded.
|
// tar.gz or tar.bz2) and sends it to be downloaded.
|
||||||
func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
query := r.URL.Query().Get("format")
|
|
||||||
|
|
||||||
// If the file isn't a directory, serve it using http.ServeFile. We display it
|
// If the file isn't a directory, serve it using http.ServeFile. We display it
|
||||||
// inline if it is requested.
|
// inline if it is requested.
|
||||||
if !c.File.IsDir {
|
if !c.File.IsDir {
|
||||||
if r.URL.Query().Get("inline") == "true" {
|
return downloadFileHandler(c, w, r)
|
||||||
w.Header().Set("Content-Disposition", "inline")
|
|
||||||
} else {
|
|
||||||
w.Header().Set("Content-Disposition", "attachment; filename=\""+c.File.Name+"\"")
|
|
||||||
}
|
|
||||||
|
|
||||||
http.ServeFile(w, r, c.File.Path)
|
|
||||||
return 0, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query := r.URL.Query().Get("format")
|
||||||
files := []string{}
|
files := []string{}
|
||||||
names := strings.Split(r.URL.Query().Get("files"), ",")
|
names := strings.Split(r.URL.Query().Get("files"), ",")
|
||||||
|
|
||||||
@@ -111,3 +103,14 @@ func downloadHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int
|
|||||||
_, err = io.Copy(w, file)
|
_, err = io.Copy(w, file)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func downloadFileHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) {
|
||||||
|
if r.URL.Query().Get("inline") == "true" {
|
||||||
|
w.Header().Set("Content-Disposition", "inline")
|
||||||
|
} else {
|
||||||
|
w.Header().Set("Content-Disposition", "attachment; filename=\""+c.File.Name+"\"")
|
||||||
|
}
|
||||||
|
|
||||||
|
http.ServeFile(w, r, c.File.Path)
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
+4
-6
@@ -25,16 +25,13 @@ func Handler(m *fm.FileManager) http.Handler {
|
|||||||
if code >= 400 {
|
if code >= 400 {
|
||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
|
|
||||||
if err == nil {
|
txt := http.StatusText(code)
|
||||||
txt := http.StatusText(code)
|
log.Printf("%v: %v %v\n", r.URL.Path, code, txt)
|
||||||
log.Printf("%v: %v %v\n", r.URL.Path, code, txt)
|
w.Write([]byte(txt + "\n"))
|
||||||
w.Write([]byte(txt))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
w.Write([]byte(err.Error()))
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -270,6 +267,7 @@ func sharePage(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, erro
|
|||||||
|
|
||||||
info, err := os.Stat(s.Path)
|
info, err := os.Stat(s.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
c.Store.Share.Delete(s.Hash)
|
||||||
return ErrorToHTTP(err, false), err
|
return ErrorToHTTP(err, false), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,6 +160,11 @@ func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
u.Rules = []*fm.Rule{}
|
u.Rules = []*fm.Rule{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the view mode is empty, initialize with the default one.
|
||||||
|
if u.ViewMode == "" {
|
||||||
|
u.ViewMode = c.DefaultUser.ViewMode
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize commands if not initialized.
|
// Initialize commands if not initialized.
|
||||||
if u.Commands == nil {
|
if u.Commands == nil {
|
||||||
u.Commands = []string{}
|
u.Commands = []string{}
|
||||||
@@ -182,6 +187,7 @@ func usersPostHandler(c *fm.Context, w http.ResponseWriter, r *http.Request) (in
|
|||||||
}
|
}
|
||||||
|
|
||||||
u.Password = pw
|
u.Password = pw
|
||||||
|
u.ViewMode = fm.MosaicViewMode
|
||||||
|
|
||||||
// Saves the user to the database.
|
// Saves the user to the database.
|
||||||
err = c.Store.Users.Save(u)
|
err = c.Store.Users.Save(u)
|
||||||
|
|||||||
Generated
+9
-9
@@ -8055,15 +8055,6 @@
|
|||||||
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=",
|
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"string_decoder": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"safe-buffer": "5.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"string-length": {
|
"string-length": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/string-length/-/string-length-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/string-length/-/string-length-1.0.1.tgz",
|
||||||
@@ -8100,6 +8091,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"string_decoder": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"safe-buffer": "5.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"strip-ansi": {
|
"strip-ansi": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
fb04f17b945f280665365cf87b85c4f8c936b31a
|
cf13216707679e7794cbc7a558b89938abaa9526
|
||||||
Reference in new issue
Block a user