refactor: rename packages

This commit is contained in:
Jason Song
2022-12-05 15:45:38 +08:00
parent fdd3444c52
commit 704f72017d
54 changed files with 81 additions and 81 deletions

25
models/actions/utils.go Normal file
View File

@ -0,0 +1,25 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package actions
import (
"encoding/hex"
auth_model "code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/modules/util"
)
func generateSaltedToken() (string, string, string, string, error) {
salt, err := util.CryptoRandomString(10)
if err != nil {
return "", "", "", "", err
}
buf, err := util.CryptoRandomBytes(20)
if err != nil {
return "", "", "", "", err
}
token := hex.EncodeToString(buf)
hash := auth_model.HashToken(token, salt)
return token, salt, hash, token[:8], nil
}