fix login on open store
This commit is contained in:
parent
1e904b7361
commit
e08bf0e99d
@ -13,8 +13,7 @@ func authorizeAdmin(r *http.Request) bool {
|
|||||||
|
|
||||||
func authorizeToken(r *http.Request, token string) bool {
|
func authorizeToken(r *http.Request, token string) bool {
|
||||||
if token == "" {
|
if token == "" {
|
||||||
// access is open
|
return false
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reqToken := r.Header.Get("Authorization")
|
reqToken := r.Header.Get("Authorization")
|
||||||
@ -30,9 +29,9 @@ func forbidden(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "Forbidden", http.StatusForbidden)
|
http.Error(w, "Forbidden", http.StatusForbidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
func requireToken(token string, handler http.Handler) http.Handler {
|
func requireToken(token *string, handler http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
if !authorizeToken(req, token) {
|
if !authorizeToken(req, *token) {
|
||||||
forbidden(w, req)
|
forbidden(w, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -41,5 +40,5 @@ func requireToken(token string, handler http.Handler) http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func requireAdmin(handler http.Handler) http.Handler {
|
func requireAdmin(handler http.Handler) http.Handler {
|
||||||
return requireToken(adminToken, handler)
|
return requireToken(&adminToken, handler)
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,9 @@
|
|||||||
<p v-if="!session.token">Not logged in.</p>
|
<p v-if="!session.token">Not logged in.</p>
|
||||||
<p v-else>Invalid token</p>
|
<p v-else>Invalid token</p>
|
||||||
|
|
||||||
<form @submit="setToken">
|
<form @submit="unlockStore">
|
||||||
<input type="password" v-model="forms.setToken" required placeholder="Token" />
|
<input type="password" v-model="forms.store.pass1" required placeholder="Passphrase" />
|
||||||
<input type="submit" value="set token"/>
|
<input type="submit" value="log in"/>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
Loading…
Reference in New Issue
Block a user