Browse Source

Merge branch 'master' of github.com:gogits/gogs

pull/31/head
Lunny Xiao 11 years ago
parent
commit
015174484a
  1. 5
      README.md
  2. 17
      models/user.go
  3. 2
      public/css/gogs.css
  4. 4
      routers/repo/single.go
  5. 8
      routers/user/user.go

5
README.md

@ -21,8 +21,9 @@ Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, devel
- SSH protocal support. - SSH protocal support.
- Register/delete account. - Register/delete account.
- Create/delete public repository. - Create/delete public repository.
- User/repository home page. - User profile page.
- Git repository manipulation. - Repository viewer.
- Gravatar support.
## Installation ## Installation

17
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) _, err = orm.Delete(user)
// TODO: delete and update follower information. // TODO: delete and update follower information.
return err return err
@ -175,8 +180,8 @@ func DeleteUser(user *User) error {
// EncodePasswd encodes password to safe format. // EncodePasswd encodes password to safe format.
func (user *User) EncodePasswd() error { func (user *User) EncodePasswd() error {
var err error newPasswd, err := scrypt.Key([]byte(user.Passwd), []byte(UserPasswdSalt), 16384, 8, 1, 64)
user.Passwd, err = EncodePasswd(user.Passwd) user.Passwd = fmt.Sprintf("%x", newPasswd)
return err return err
} }
@ -184,14 +189,6 @@ func UserPath(userName string) string {
return filepath.Join(RepoRootPath, userName) 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) { func GetUserByKeyId(keyId int64) (*User, error) {
user := new(User) 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) 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)

2
public/css/gogs.css

@ -580,7 +580,7 @@ html, body {
} }
.file-list .date .wrap { .file-list .date .wrap {
max-width: 100px; max-width: 120px;
padding: 0 20px 0 0; padding: 0 20px 0 0;
} }

4
routers/repo/single.go

@ -46,11 +46,12 @@ func Single(ctx *middleware.Context, params martini.Params) {
ctx.Data["Paths"] = Paths ctx.Data["Paths"] = Paths
ctx.Data["Treenames"] = treenames ctx.Data["Treenames"] = treenames
ctx.Data["IsRepoToolbarSource"] = true ctx.Data["IsRepoToolbarSource"] = true
ctx.Data["IsRepositoryOwner"] = strings.ToLower(params["username"]) == ctx.User.LowerName
ctx.Data["Files"] = files ctx.Data["Files"] = files
ctx.Render.HTML(200, "repo/single", ctx.Data) 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 { if !ctx.Repo.IsValid {
return return
} }
@ -62,6 +63,7 @@ func Setting(ctx *middleware.Context) {
ctx.Data["Title"] = title + " - settings" ctx.Data["Title"] = title + " - settings"
ctx.Data["IsRepoToolbarSetting"] = true ctx.Data["IsRepoToolbarSetting"] = true
ctx.Data["IsRepositoryOwner"] = strings.ToLower(params["username"]) == ctx.User.LowerName
ctx.Render.HTML(200, "repo/setting", ctx.Data) ctx.Render.HTML(200, "repo/setting", ctx.Data)
} }

8
routers/user/user.go

@ -157,11 +157,11 @@ func Delete(ctx *middleware.Context) {
return return
} }
rawPasswd := ctx.Query("password") tmpUser := models.User{Passwd: ctx.Query("password")}
encodedPwd, _ := models.EncodePasswd(rawPasswd) tmpUser.EncodePasswd()
if len(encodedPwd) == 0 || encodedPwd != ctx.User.Passwd { if len(tmpUser.Passwd) == 0 || tmpUser.Passwd != ctx.User.Passwd {
ctx.Data["HasError"] = true 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 { } else {
if err := models.DeleteUser(ctx.User); err != nil { if err := models.DeleteUser(ctx.User); err != nil {
ctx.Data["HasError"] = true ctx.Data["HasError"] = true

Loading…
Cancel
Save