aboutsummaryrefslogtreecommitdiff
path: root/internal/route/user
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-03-21 13:39:32 +0800
committerGitHub <noreply@github.com>2020-03-21 13:39:32 +0800
commit5843038a0812cc133c1895b7410aeda7153e8708 (patch)
tree3515998242443e1a82217ee4702603819c5315c8 /internal/route/user
parent958d8b6bb4c2da66859325695b91d871e567a4fa (diff)
workflows: enable golangci-lint (#5998)
* Create golint.yml * Update golint.yml * Update golint.yml * Fix errcheck * Fix gosimple * Fix staticcheck
Diffstat (limited to 'internal/route/user')
-rw-r--r--internal/route/user/auth.go24
-rw-r--r--internal/route/user/setting.go12
2 files changed, 19 insertions, 17 deletions
diff --git a/internal/route/user/auth.go b/internal/route/user/auth.go
index 5fef81c3..a29b6311 100644
--- a/internal/route/user/auth.go
+++ b/internal/route/user/auth.go
@@ -64,8 +64,8 @@ func AutoLogin(c *context.Context) (bool, error) {
}
isSucceed = true
- c.Session.Set("uid", u.ID)
- c.Session.Set("uname", u.Name)
+ _ = c.Session.Set("uid", u.ID)
+ _ = c.Session.Set("uname", u.Name)
c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath)
if conf.Security.EnableLoginStatusCookie {
c.SetCookie(conf.Security.LoginStatusCookieName, "true", 0, conf.Server.Subpath)
@@ -124,10 +124,10 @@ func afterLogin(c *context.Context, u *db.User, remember bool) {
c.SetSuperSecureCookie(u.Rands+u.Passwd, conf.Security.CookieRememberName, u.Name, days, conf.Server.Subpath, "", conf.Security.CookieSecure, true)
}
- c.Session.Set("uid", u.ID)
- c.Session.Set("uname", u.Name)
- c.Session.Delete("twoFactorRemember")
- c.Session.Delete("twoFactorUserID")
+ _ = c.Session.Set("uid", u.ID)
+ _ = c.Session.Set("uname", u.Name)
+ _ = c.Session.Delete("twoFactorRemember")
+ _ = c.Session.Delete("twoFactorUserID")
// Clear whatever CSRF has right now, force to generate a new one
c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath)
@@ -187,8 +187,8 @@ func LoginPost(c *context.Context, f form.SignIn) {
return
}
- c.Session.Set("twoFactorRemember", f.Remember)
- c.Session.Set("twoFactorUserID", u.ID)
+ _ = c.Session.Set("twoFactorRemember", f.Remember)
+ _ = c.Session.Set("twoFactorUserID", u.ID)
c.RedirectSubpath("/user/login/two_factor")
}
@@ -281,8 +281,8 @@ func LoginTwoFactorRecoveryCodePost(c *context.Context) {
}
func SignOut(c *context.Context) {
- c.Session.Flush()
- c.Session.Destory(c.Context)
+ _ = c.Session.Flush()
+ _ = c.Session.Destory(c.Context)
c.SetCookie(conf.Security.CookieUsername, "", -1, conf.Server.Subpath)
c.SetCookie(conf.Security.CookieRememberName, "", -1, conf.Server.Subpath)
c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath)
@@ -426,8 +426,8 @@ func Activate(c *context.Context) {
log.Trace("User activated: %s", user.Name)
- c.Session.Set("uid", user.ID)
- c.Session.Set("uname", user.Name)
+ _ = c.Session.Set("uid", user.ID)
+ _ = c.Session.Set("uname", user.Name)
c.RedirectSubpath("/")
return
}
diff --git a/internal/route/user/setting.go b/internal/route/user/setting.go
index d8ae9e70..c9ccdc8f 100644
--- a/internal/route/user/setting.go
+++ b/internal/route/user/setting.go
@@ -127,7 +127,9 @@ func UpdateAvatarSetting(c *context.Context, f form.Avatar, ctxUser *db.User) er
if err != nil {
return fmt.Errorf("open avatar reader: %v", err)
}
- defer r.Close()
+ defer func() {
+ _ = r.Close()
+ }()
data, err := ioutil.ReadAll(r)
if err != nil {
@@ -429,8 +431,8 @@ func SettingsTwoFactorEnable(c *context.Context) {
}
c.Data["QRCode"] = template.URL("data:image/png;base64," + base64.StdEncoding.EncodeToString(buf.Bytes()))
- c.Session.Set("twoFactorSecret", c.Data["TwoFactorSecret"])
- c.Session.Set("twoFactorURL", key.String())
+ _ = c.Session.Set("twoFactorSecret", c.Data["TwoFactorSecret"])
+ _ = c.Session.Set("twoFactorURL", key.String())
c.Success(SETTINGS_TWO_FACTOR_ENABLE)
}
@@ -453,8 +455,8 @@ func SettingsTwoFactorEnablePost(c *context.Context) {
return
}
- c.Session.Delete("twoFactorSecret")
- c.Session.Delete("twoFactorURL")
+ _ = c.Session.Delete("twoFactorSecret")
+ _ = c.Session.Delete("twoFactorURL")
c.Flash.Success(c.Tr("settings.two_factor_enable_success"))
c.RedirectSubpath("/user/settings/security/two_factor_recovery_codes")
}