summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-03-16 23:03:27 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-03-16 23:03:27 +0800
commit015174484a3aa430e30801e0c3c5ce0bdc4a5bf5 (patch)
tree998a2362f2d8ba7f22f1a0bb55bb70cf6f3988c0 /models
parent1fb457ac1f46ef07557f5c8c5b84438f2325a5cf (diff)
parent9249ceaff2802ab571f163a9a163b716e5ee26cc (diff)
downloadgitea-015174484a3aa430e30801e0c3c5ce0bdc4a5bf5.tar.gz
gitea-015174484a3aa430e30801e0c3c5ce0bdc4a5bf5.zip
Merge branch 'master' of github.com:gogits/gogs
Diffstat (limited to 'models')
-rw-r--r--models/user.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/models/user.go b/models/user.go
index 4b5a110915..c42599de99 100644
--- a/models/user.go
+++ b/models/user.go
@@ -168,6 +168,11 @@ func DeleteUser(user *User) error {
}
}
+ // Delete user directory.
+ if err = os.RemoveAll(UserPath(user.Name)); err != nil {
+ return err
+ }
+
_, err = orm.Delete(user)
// TODO: delete and update follower information.
return err
@@ -175,8 +180,8 @@ func DeleteUser(user *User) error {
// EncodePasswd encodes password to safe format.
func (user *User) EncodePasswd() error {
- var err error
- user.Passwd, err = EncodePasswd(user.Passwd)
+ newPasswd, err := scrypt.Key([]byte(user.Passwd), []byte(UserPasswdSalt), 16384, 8, 1, 64)
+ user.Passwd = fmt.Sprintf("%x", newPasswd)
return err
}
@@ -184,14 +189,6 @@ func UserPath(userName string) string {
return filepath.Join(RepoRootPath, userName)
}
-func EncodePasswd(rawPasswd string) (string, error) {
- newPasswd, err := scrypt.Key([]byte(rawPasswd), []byte(UserPasswdSalt), 16384, 8, 1, 64)
- if err != nil {
- return "", err
- }
- return fmt.Sprintf("%x", newPasswd), nil
-}
-
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)