Skip to content

Commit

Permalink
update index page
Browse files Browse the repository at this point in the history
  • Loading branch information
nor authored and PterX committed Mar 28, 2024
1 parent e5dc89b commit d5c39ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
6 changes: 0 additions & 6 deletions internal/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ func newServerCommand() *cobra.Command {
cmd.Flags().Bool("access-log", false, "Print out a non-standard access log")
cmd.Flags().Bool("serve-web-ui", true, "Serve static files from the webroot path")
cmd.Flags().String("secret-key", "", "Secret key used for encrypting session data")
cmd.Flags().StringSlice("trusted-proxies", []string{}, "list of trusted proxy IPs, empty means no proxy allowed")
cmd.Flags().String("reverse-proxy-auth-user", "", "http header name of proxy auth")

return cmd
}
Expand All @@ -40,8 +38,6 @@ func newServerCommandHandler() func(cmd *cobra.Command, args []string) {
accessLog, _ := cmd.Flags().GetBool("access-log")
serveWebUI, _ := cmd.Flags().GetBool("serve-web-ui")
secretKey, _ := cmd.Flags().GetBytesHex("secret-key")
trustedProxies, _ := cmd.Flags().GetStringSlice("trusted-proxies")
reverseProxyAuthUser, _ := cmd.Flags().GetString("reverse-proxy-auth-user")

cfg, dependencies := initShiori(ctx, cmd)

Expand All @@ -65,8 +61,6 @@ func newServerCommandHandler() func(cmd *cobra.Command, args []string) {
cfg.Http.AccessLog = accessLog
cfg.Http.ServeWebUI = serveWebUI
cfg.Http.SecretKey = secretKey
cfg.Http.TrustedProxies = trustedProxies
cfg.Http.ReverseProxyAuthUser = reverseProxyAuthUser

dependencies.Log.Infof("Starting Shiori v%s", model.BuildVersion)

Expand Down
25 changes: 24 additions & 1 deletion internal/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,32 @@
username: username,
owner: owner,
};
}
},
loadToken() {
function parseJWT(token) {
try {
return JSON.parse(atob(token.split('.')[1]));
} catch (e) {
return null;
}
}
function getCookie(cname){
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
}
return "";
}
// Save account data
var token = getCookie("token");
localStorage.setItem("shiori-token", token);
localStorage.setItem("shiori-account", JSON.stringify(parseJWT(token).account));
}
},
mounted() {
this.loadToken();
// Load setting
this.loadSetting();
this.loadAccount();
Expand Down

0 comments on commit d5c39ad

Please sign in to comment.