]> source.dussan.org Git - gitea.git/commitdiff
Bug fix
authorUnknown <joe2010xtmf@163.com>
Sun, 16 Mar 2014 14:35:25 +0000 (10:35 -0400)
committerUnknown <joe2010xtmf@163.com>
Sun, 16 Mar 2014 14:35:25 +0000 (10:35 -0400)
README.md
models/user.go
routers/repo/single.go
routers/user/user.go

index 0fb646e5e05afab09e32de34188bac87b49722f2..f4250a47a455281f9533cdafbdc824705b9248df 100644 (file)
--- a/README.md
+++ b/README.md
@@ -21,8 +21,9 @@ Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, devel
 - SSH protocal support.
 - Register/delete account.
 - Create/delete public repository.
-- User/repository home page.
-- Git repository manipulation.
+- User profile page.
+- Repository viewer.
+- Gravatar support.
 
 ## Installation
 
index 4b5a11091542069ff7dd4e13b87efe723cdfa44b..c42599de9983f5c5b6330069673feb9cf3984dcf 100644 (file)
@@ -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)
index eda30c00a63736d3fd74bbea85d047cfb5eeb2d3..6bf03ca2b8a8ed714cbba435a6d4e0ab4210099f 100644 (file)
@@ -46,11 +46,12 @@ func Single(ctx *middleware.Context, params martini.Params) {
        ctx.Data["Paths"] = Paths
        ctx.Data["Treenames"] = treenames
        ctx.Data["IsRepoToolbarSource"] = true
+       ctx.Data["IsRepositoryOwner"] = strings.ToLower(params["username"]) == ctx.User.LowerName
        ctx.Data["Files"] = files
        ctx.Render.HTML(200, "repo/single", ctx.Data)
 }
 
-func Setting(ctx *middleware.Context) {
+func Setting(ctx *middleware.Context, params martini.Params) {
        if !ctx.Repo.IsValid {
                return
        }
@@ -62,6 +63,7 @@ func Setting(ctx *middleware.Context) {
 
        ctx.Data["Title"] = title + " - settings"
        ctx.Data["IsRepoToolbarSetting"] = true
+       ctx.Data["IsRepositoryOwner"] = strings.ToLower(params["username"]) == ctx.User.LowerName
        ctx.Render.HTML(200, "repo/setting", ctx.Data)
 }
 
index ad84ff6c799c8b1ba235f7ccf4d9368015639b0a..0ff5058dcc0a10897e92f4dfd666f68d889a9aa3 100644 (file)
@@ -157,11 +157,11 @@ func Delete(ctx *middleware.Context) {
                return
        }
 
-       rawPasswd := ctx.Query("password")
-       encodedPwd, _ := models.EncodePasswd(rawPasswd)
-       if len(encodedPwd) == 0 || encodedPwd != ctx.User.Passwd {
+       tmpUser := models.User{Passwd: ctx.Query("password")}
+       tmpUser.EncodePasswd()
+       if len(tmpUser.Passwd) == 0 || tmpUser.Passwd != ctx.User.Passwd {
                ctx.Data["HasError"] = true
-               ctx.Data["ErrorMsg"] = "Your password error. Make sure you are owner of this account."
+               ctx.Data["ErrorMsg"] = "Password is not correct. Make sure you are owner of this account."
        } else {
                if err := models.DeleteUser(ctx.User); err != nil {
                        ctx.Data["HasError"] = true