Compare commits

...
3 Commits
Author SHA1 Message Date
Henrique Dias aeb0f37e20 Version 1.3.9
Former-commit-id: 9c7d15644bcab9e3babc8d645615e50d99187871 [formerly f0a0bf08c328b801cc6ed5add830732c99f92047] [formerly 250bc983264deb841b2115a03610b8e6f473f1ca [formerly b903356b94]]
Former-commit-id: 56bb31f4e44ad39a65f1d1eaa0a8e493287fad7f [formerly e120e69e05cc67f377a83f19f4106b7be945780f]
Former-commit-id: 36fb7783992200295b2f9811b97c2312977023a4
2017-10-31 19:20:36 +00:00
Henrique Dias 59a0daa293 Fix ViewMode related bugs:
- The user will no longer lost their 'ViewMode' option after being updated in the settings.
- The console will not output errors due tot he scroll function when Mosaic mode is on.


Former-commit-id: 97aa6abdc8b864dc7a55dbf03a2e58895ea7613f [formerly ff9e6ff0898f32bd106b644b2e9002b5de45281c] [formerly 556cc12bd5ff1d91776c81f48dd1dceb8bb627b4 [formerly 51104c5ee7]]
Former-commit-id: dd63b2b818a7bd4960a7243866d6b2829f4c03a8 [formerly 45855d70eaa9a2b060d3a89cb70388040ea8e6d9]
Former-commit-id: 6e0ebf10d7fe3e2c234abc9c0ffd447cfbdd7455
2017-10-31 18:23:31 +00:00
Henrique Dias c716d126eb [ci skip] auto: setting untracked version
Former-commit-id: 88d8cc322b27fc1165a53779e7226db8fd6f90ab [formerly 7f0e5a193dba73cb133bd4d72cd0d81bdc354736] [formerly da79e8c40409e5b5995749556155cccd8a0325cd [formerly cc5f3ac1dd]]
Former-commit-id: 47f0176b53e3a5b2eb402eba29a07f51b7d0c7a7 [formerly c1d2d78eb8827f3386080b0309e6cef66bfed9b1]
Former-commit-id: 64c1ec091ce58eb6b38b0281b7a728b2ca07fe1a
2017-10-30 16:24:48 +00:00
7 changed files with 63 additions and 43 deletions

No files matched your search

+1 -1
View File
@@ -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
+31 -20
View File
@@ -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')
+2 -2
View File
@@ -24,7 +24,7 @@ import (
// Version is the current File Manager version. // Version is the current File Manager version.
const ( const (
// Version is the current File Manager version. // Version is the current File Manager version.
Version = "1.3.8" Version = "1.3.9"
ListViewMode = "list" ListViewMode = "list"
MosaicViewMode = "mosaic" MosaicViewMode = "mosaic"
@@ -39,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
+10 -9
View File
@@ -1,7 +1,6 @@
package http package http
import ( import (
"bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@@ -14,22 +13,23 @@ import (
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
View File
@@ -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
}
+5
View File
@@ -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{}
+1 -1
View File
@@ -1 +1 @@
9536ea589ebfb34b4ccbf549776ff8b4c70d6dd6 cf13216707679e7794cbc7a558b89938abaa9526