aboutsummaryrefslogtreecommitdiff
path: root/internal/userutil/userutil.go
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2022-11-05 17:55:05 +0800
committerGitHub <noreply@github.com>2022-11-05 17:55:05 +0800
commitfd798b4197dc53df872d20f5d10edb8d73c32386 (patch)
treee59c8e5881f2162e211850ede549a1f57df64515 /internal/userutil/userutil.go
parenta66c90462da24a916ee62afcb5a1f79d06ed8399 (diff)
refactor(db): migrate methods off `user.go` (#7228)
Diffstat (limited to 'internal/userutil/userutil.go')
-rw-r--r--internal/userutil/userutil.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/userutil/userutil.go b/internal/userutil/userutil.go
index 6d324ff6..bafdaf58 100644
--- a/internal/userutil/userutil.go
+++ b/internal/userutil/userutil.go
@@ -23,6 +23,7 @@ import (
"gogs.io/gogs/internal/avatar"
"gogs.io/gogs/internal/conf"
+ "gogs.io/gogs/internal/strutil"
"gogs.io/gogs/internal/tool"
)
@@ -132,3 +133,9 @@ func MailResendCacheKey(userID int64) string {
func TwoFactorCacheKey(userID int64, passcode string) string {
return fmt.Sprintf("twoFactor::%d::%s", userID, passcode)
}
+
+// RandomSalt returns randomly generated 10-character string that can be used as
+// the user salt.
+func RandomSalt() (string, error) {
+ return strutil.RandomChars(10)
+}