diff --git a/public/style.css b/public/style.css index 7fd5e99b..1de12d9d 100644 --- a/public/style.css +++ b/public/style.css @@ -9415,6 +9415,10 @@ span.icon-rss::before { background-color: #43a52f; background-color: var(--notice-success-color); } +.notice-warn { + background-color: #aa7d30; + background-color: var(--notice-warn-color); } + .notice-failure { background-color: #b42222; background-color: var(--notice-failure-color); } diff --git a/public/themes/dark/theme.css b/public/themes/dark/theme.css index 7a9a4017..5a2b8fa6 100644 --- a/public/themes/dark/theme.css +++ b/public/themes/dark/theme.css @@ -244,6 +244,7 @@ pre, code, .codeblock { --notice-lts-color: #2a681d; --notice-lts-reqd-color: #876327; --notice-success-color: #2a681d; + --notice-warn-color: #876327; --notice-failure-color: #7a2020; --optionbar-border-color: #333; --tab-background: #181818; diff --git a/public/themes/light/theme.css b/public/themes/light/theme.css index 50355b2a..627dfdf9 100644 --- a/public/themes/light/theme.css +++ b/public/themes/light/theme.css @@ -262,6 +262,7 @@ pre, code, .codeblock { --notice-lts-color: #43a52f; --notice-lts-reqd-color: #aa7d30; --notice-success-color: #43a52f; + --notice-warn-color: #aa7d30; --notice-failure-color: #b42222; --optionbar-border-color: #ccc; --tab-background: #fff; diff --git a/src/rawdata/scss/_notices.scss b/src/rawdata/scss/_notices.scss index 6b4efdf8..3da627f2 100644 --- a/src/rawdata/scss/_notices.scss +++ b/src/rawdata/scss/_notices.scss @@ -36,6 +36,10 @@ @include usevar(background-color, notice-success-color); } +.notice-warn { + @include usevar(background-color, notice-warn-color); +} + .notice-failure { @include usevar(background-color, notice-failure-color); } diff --git a/src/rawdata/scss/themes/dark/_variables.scss b/src/rawdata/scss/themes/dark/_variables.scss index 4ca3469e..da909697 100644 --- a/src/rawdata/scss/themes/dark/_variables.scss +++ b/src/rawdata/scss/themes/dark/_variables.scss @@ -46,6 +46,7 @@ $vars: ( notice-lts-color: #2a681d, notice-lts-reqd-color: #876327, notice-success-color: #2a681d, + notice-warn-color: #876327, notice-failure-color: #7a2020, optionbar-border-color: #333, diff --git a/src/rawdata/scss/themes/light/_variables.scss b/src/rawdata/scss/themes/light/_variables.scss index e47035ad..22a0ecb6 100644 --- a/src/rawdata/scss/themes/light/_variables.scss +++ b/src/rawdata/scss/themes/light/_variables.scss @@ -46,6 +46,7 @@ $vars: ( notice-lts-color: #43a52f, notice-lts-reqd-color: #aa7d30, notice-success-color: #43a52f, + notice-warn-color: #aa7d30, notice-failure-color: #b42222, optionbar-border-color: #ccc, diff --git a/src/website/auth.go b/src/website/auth.go index 7f86f1eb..57a6c306 100644 --- a/src/website/auth.go +++ b/src/website/auth.go @@ -41,10 +41,6 @@ func LoginPage(c *RequestContext) ResponseData { } func Login(c *RequestContext) ResponseData { - if c.CurrentUser != nil { - return RejectRequest(c, "You are already logged in.") - } - form, err := c.GetFormValues() if err != nil { return c.ErrorResponse(http.StatusBadRequest, NewSafeError(err, "request must contain form data")) @@ -55,6 +51,12 @@ func Login(c *RequestContext) ResponseData { redirect = "/" } + if c.CurrentUser != nil { + res := c.Redirect(redirect, http.StatusSeeOther) + res.AddFutureNotice("warn", fmt.Sprintf("You are already logged in as %s.", c.CurrentUser.Username)) + return res + } + username := form.Get("username") password := form.Get("password") if username == "" || password == "" {