Merge login page with settings page

This commit is contained in:
VnPower
2024-02-08 14:32:42 +07:00
parent bcf9adc927
commit 60ae330d7b
4 changed files with 39 additions and 13 deletions
-1
View File
@@ -147,7 +147,6 @@ func main() {
server.Get("artworks/:id/", pages.ArtworkPage).Name("artworks")
// Settings group
server.Get("login", pages.LoginPage)
settings := server.Group("settings")
settings.Get("/", pages.SettingsPage)
settings.Post("/:type", pages.SettingsPost)
+3 -3
View File
@@ -13,7 +13,7 @@ func LoginUserPage(c *fiber.Ctx) error {
token := session.CheckToken(c)
if token == "" {
return c.Redirect("/login")
return c.Redirect("/settings")
}
// The left part of the token is the member ID
@@ -26,7 +26,7 @@ func LoginUserPage(c *fiber.Ctx) error {
func LoginBookmarkPage(c *fiber.Ctx) error {
token := session.CheckToken(c)
if token == "" {
return c.Redirect("/login")
return c.Redirect("/settings")
}
// The left part of the token is the member ID
@@ -38,7 +38,7 @@ func LoginBookmarkPage(c *fiber.Ctx) error {
func FollowingWorksPage(c *fiber.Ctx) error {
if token := session.CheckToken(c); token == "" {
return c.Redirect("/login")
return c.Redirect("/settings")
}
mode := c.Query("mode", "all")
+1 -5
View File
@@ -78,10 +78,6 @@ func setLogout(c *fiber.Ctx) error {
return nil
}
func LoginPage(c *fiber.Ctx) error {
return c.Render("pages/login", fiber.Map{})
}
func SettingsPage(c *fiber.Ctx) error {
return c.Render("pages/settings", fiber.Map{})
}
@@ -104,6 +100,6 @@ func SettingsPost(c *fiber.Ctx) error {
if err != nil {
return err
}
c.Redirect("/settings")
c.Redirect("/")
return nil
}
+35 -4
View File
@@ -1,9 +1,40 @@
<div class="container">
<h2>Login</h2>
<p>Go to <a href="/login">this page</a> to login</p>
<h2>Settings</h2>
<h2>Login</h2>
<p>Supported features (for now):</p>
<ul>
<li>Discovery page</li>
<li>Landing page</li>
</ul>
<p>
You can only login using your account's cookie, check out
<a
href="https://codeberg.org/VnPower/pixivfe/wiki/How-to-get-the-cookie-%28PIXIVFE_TOKEN%29"
>this page</a
>
to see how to get it.
</p>
<p>
Note that you will get logged out automatically every time the server
updates, if you are logged in before but got logged out recently, it is
probably because the instance owner restarted the server.
</p>
<form action="/settings/token" method="post">
<input type="text" name="token" autocomplete="off" />
<input type="submit" value="Apply" />
</form>
<hr />
<h2>Logout</h2>
<p>
You can safely logout here. This button will just delete the token directly
from this session.
</p>
<form action="/settings/logout" method="post">
<input type="submit" value="Logout!" />
</form>
<hr />
<h2>Image proxy server</h2>
<div class="form-field">
<h3>Image proxy server</h3>
<form action="/settings/image_server" method="post">
<input type="radio" name="image-proxy" id="image-proxy" value="pixiv.tatakai.top" />
<label for="image-proxy">pixiv.tatakai.top</label>