mirror of
https://github.com/go-gitea/gitea
synced 2025-07-16 07:18:37 +00:00
improved ssh supports
This commit is contained in:
@@ -7,12 +7,15 @@ package models
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/dchest/scrypt"
|
||||
|
||||
"github.com/gogits/gogs/utils"
|
||||
"github.com/gogits/gogs/utils/log"
|
||||
)
|
||||
|
||||
// User types.
|
||||
@@ -96,10 +99,22 @@ func RegisterUser(user *User) (err error) {
|
||||
|
||||
user.LowerName = strings.ToLower(user.Name)
|
||||
user.Avatar = utils.EncodeMd5(user.Email)
|
||||
user.Updated = time.Now()
|
||||
user.EncodePasswd()
|
||||
_, err = orm.Insert(user)
|
||||
return err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.MkdirAll(UserPath(user.Name), os.ModePerm)
|
||||
if err != nil {
|
||||
_, err2 := orm.Id(user.Id).Delete(&User{})
|
||||
if err2 != nil {
|
||||
log.Error("create userpath %s failed and delete table record faild",
|
||||
user.Name)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateUser updates user's information.
|
||||
@@ -129,6 +144,10 @@ func (user *User) EncodePasswd() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func UserPath(userName string) string {
|
||||
return filepath.Join(RepoRootPath, userName)
|
||||
}
|
||||
|
||||
func GetUserByKeyId(keyId int64) (*User, error) {
|
||||
user := new(User)
|
||||
has, err := orm.Sql("select a.* from user as a, public_key as b where a.id = b.owner_id and b.id=?", keyId).Get(user)
|
||||
|
Reference in New Issue
Block a user