Replaced relogin rejection with a notice and proper redirect.

This commit is contained in:
Asaf Gartner 2021-09-05 22:50:15 +03:00
parent e74b18967e
commit c76ea45ca9
7 changed files with 18 additions and 4 deletions

View File

@ -9415,6 +9415,10 @@ span.icon-rss::before {
background-color: #43a52f; background-color: #43a52f;
background-color: var(--notice-success-color); } background-color: var(--notice-success-color); }
.notice-warn {
background-color: #aa7d30;
background-color: var(--notice-warn-color); }
.notice-failure { .notice-failure {
background-color: #b42222; background-color: #b42222;
background-color: var(--notice-failure-color); } background-color: var(--notice-failure-color); }

View File

@ -244,6 +244,7 @@ pre, code, .codeblock {
--notice-lts-color: #2a681d; --notice-lts-color: #2a681d;
--notice-lts-reqd-color: #876327; --notice-lts-reqd-color: #876327;
--notice-success-color: #2a681d; --notice-success-color: #2a681d;
--notice-warn-color: #876327;
--notice-failure-color: #7a2020; --notice-failure-color: #7a2020;
--optionbar-border-color: #333; --optionbar-border-color: #333;
--tab-background: #181818; --tab-background: #181818;

View File

@ -262,6 +262,7 @@ pre, code, .codeblock {
--notice-lts-color: #43a52f; --notice-lts-color: #43a52f;
--notice-lts-reqd-color: #aa7d30; --notice-lts-reqd-color: #aa7d30;
--notice-success-color: #43a52f; --notice-success-color: #43a52f;
--notice-warn-color: #aa7d30;
--notice-failure-color: #b42222; --notice-failure-color: #b42222;
--optionbar-border-color: #ccc; --optionbar-border-color: #ccc;
--tab-background: #fff; --tab-background: #fff;

View File

@ -36,6 +36,10 @@
@include usevar(background-color, notice-success-color); @include usevar(background-color, notice-success-color);
} }
.notice-warn {
@include usevar(background-color, notice-warn-color);
}
.notice-failure { .notice-failure {
@include usevar(background-color, notice-failure-color); @include usevar(background-color, notice-failure-color);
} }

View File

@ -46,6 +46,7 @@ $vars: (
notice-lts-color: #2a681d, notice-lts-color: #2a681d,
notice-lts-reqd-color: #876327, notice-lts-reqd-color: #876327,
notice-success-color: #2a681d, notice-success-color: #2a681d,
notice-warn-color: #876327,
notice-failure-color: #7a2020, notice-failure-color: #7a2020,
optionbar-border-color: #333, optionbar-border-color: #333,

View File

@ -46,6 +46,7 @@ $vars: (
notice-lts-color: #43a52f, notice-lts-color: #43a52f,
notice-lts-reqd-color: #aa7d30, notice-lts-reqd-color: #aa7d30,
notice-success-color: #43a52f, notice-success-color: #43a52f,
notice-warn-color: #aa7d30,
notice-failure-color: #b42222, notice-failure-color: #b42222,
optionbar-border-color: #ccc, optionbar-border-color: #ccc,

View File

@ -41,10 +41,6 @@ func LoginPage(c *RequestContext) ResponseData {
} }
func Login(c *RequestContext) ResponseData { func Login(c *RequestContext) ResponseData {
if c.CurrentUser != nil {
return RejectRequest(c, "You are already logged in.")
}
form, err := c.GetFormValues() form, err := c.GetFormValues()
if err != nil { if err != nil {
return c.ErrorResponse(http.StatusBadRequest, NewSafeError(err, "request must contain form data")) return c.ErrorResponse(http.StatusBadRequest, NewSafeError(err, "request must contain form data"))
@ -55,6 +51,12 @@ func Login(c *RequestContext) ResponseData {
redirect = "/" 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") username := form.Get("username")
password := form.Get("password") password := form.Get("password")
if username == "" || password == "" { if username == "" || password == "" {