Browse Source

fix #622

pull/626/head
Unknwon 10 years ago
parent
commit
9e22840483
  1. 4
      .bra.toml
  2. 1
      .gopmfile
  3. 10
      cmd/serve.go
  4. 2
      conf/locale/locale_en-US.ini
  5. 8
      models/user.go
  6. 3
      routers/admin/users.go
  7. 3
      routers/user/setting.go

4
.bra.toml

@ -14,7 +14,7 @@ watch_dirs = [
watch_exts = [".go", ".ini"] watch_exts = [".go", ".ini"]
build_delay = 1500 build_delay = 1500
cmds = [ cmds = [
["go", "install", "-tags", "sqlite redis cert"], ["go", "install", "-tags", "sqlite cert"],# redis memcache
["go", "build", "-tags", "sqlite redis cert"], ["go", "build", "-tags", "sqlite cert"],
["./gogs", "web"] ["./gogs", "web"]
] ]

1
.gopmfile

@ -13,7 +13,6 @@ github.com/codegangsta/cli = commit:7381bc4e62
github.com/go-sql-driver/mysql = commit:8111ee3ec3 github.com/go-sql-driver/mysql = commit:8111ee3ec3
github.com/go-xorm/core = github.com/go-xorm/core =
github.com/go-xorm/xorm = github.com/go-xorm/xorm =
github.com/gogits/gfm = commit:40f747a9c0
github.com/gogits/oauth2 = commit:99cbec870a github.com/gogits/oauth2 = commit:99cbec870a
github.com/lib/pq = commit:b021d0ef20 github.com/lib/pq = commit:b021d0ef20
github.com/macaron-contrib/binding = github.com/macaron-contrib/binding =

10
cmd/serve.go

@ -96,7 +96,7 @@ func runServ(k *cli.Context) {
println("Gogs: you are not the owner of SSH key") println("Gogs: you are not the owner of SSH key")
log.GitLogger.Fatal(2, "Invalid owner of SSH key: %d", keyId) log.GitLogger.Fatal(2, "Invalid owner of SSH key: %d", keyId)
} }
println("Gogs: internal error:", err) println("Gogs: internal error:", err.Error())
log.GitLogger.Fatal(2, "Fail to get user by key ID(%d): %v", keyId, err) log.GitLogger.Fatal(2, "Fail to get user by key ID(%d): %v", keyId, err)
} }
@ -125,7 +125,7 @@ func runServ(k *cli.Context) {
println("Gogs: given repository owner are not registered") println("Gogs: given repository owner are not registered")
log.GitLogger.Fatal(2, "Unregistered owner: %s", repoUserName) log.GitLogger.Fatal(2, "Unregistered owner: %s", repoUserName)
} }
println("Gogs: internal error:", err) println("Gogs: internal error:", err.Error())
log.GitLogger.Fatal(2, "Fail to get repository owner(%s): %v", repoUserName, err) log.GitLogger.Fatal(2, "Fail to get repository owner(%s): %v", repoUserName, err)
} }
@ -134,7 +134,7 @@ func runServ(k *cli.Context) {
case isWrite: case isWrite:
has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.WRITABLE) has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.WRITABLE)
if err != nil { if err != nil {
println("Gogs: internal error:", err) println("Gogs: internal error:", err.Error())
log.GitLogger.Fatal(2, "Fail to check write access:", err) log.GitLogger.Fatal(2, "Fail to check write access:", err)
} else if !has { } else if !has {
println("You have no right to write this repository") println("You have no right to write this repository")
@ -147,7 +147,7 @@ func runServ(k *cli.Context) {
println("Gogs: given repository does not exist") println("Gogs: given repository does not exist")
log.GitLogger.Fatal(2, "Repository does not exist: %s/%s", repoUser.Name, repoName) log.GitLogger.Fatal(2, "Repository does not exist: %s/%s", repoUser.Name, repoName)
} }
println("Gogs: internal error:", err) println("Gogs: internal error:", err.Error())
log.GitLogger.Fatal(2, "Fail to get repository: %v", err) log.GitLogger.Fatal(2, "Fail to get repository: %v", err)
} }
@ -157,7 +157,7 @@ func runServ(k *cli.Context) {
has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.READABLE) has, err := models.HasAccess(user.Name, path.Join(repoUserName, repoName), models.READABLE)
if err != nil { if err != nil {
println("Gogs: internal error:", err) println("Gogs: internal error:", err.Error())
log.GitLogger.Fatal(2, "Fail to check read access:", err) log.GitLogger.Fatal(2, "Fail to check read access:", err)
} else if !has { } else if !has {
println("You have no right to access this repository") println("You have no right to access this repository")

2
conf/locale/locale_en-US.ini

@ -164,6 +164,7 @@ unable_verify_ssh_key = Gogs cannot verify your SSH key, but we assume that is v
auth_failed = Authentication failed: %v auth_failed = Authentication failed: %v
still_own_repo = Your account still have ownership of repository, you have to delete or transfer them first. still_own_repo = Your account still have ownership of repository, you have to delete or transfer them first.
still_has_org = Your account still have membership of organization, you have to left or delete them first.
org_still_own_repo = This organization still have ownership of repository, you have to delete or transfer them first. org_still_own_repo = This organization still have ownership of repository, you have to delete or transfer them first.
still_own_user = This authentication still has used by some users, you should move them and then delete again. still_own_user = This authentication still has used by some users, you should move them and then delete again.
@ -510,6 +511,7 @@ users.is_admin = This account has administrator permissions
users.update_profile = Update Account Profile users.update_profile = Update Account Profile
users.delete_account = Delete This Account users.delete_account = Delete This Account
users.still_own_repo = This account still have ownership of repository, you have to delete or transfer them first. users.still_own_repo = This account still have ownership of repository, you have to delete or transfer them first.
users.still_has_org = This account still have membership of organization, you have to left or delete them first.
orgs.org_manage_panel = Organization Manage Panel orgs.org_manage_panel = Organization Manage Panel
orgs.name = Name orgs.name = Name

8
models/user.go

@ -376,7 +376,7 @@ func UpdateUser(u *User) error {
return err return err
} }
// TODO: need some kind of mechanism to record failure. // FIXME: need some kind of mechanism to record failure. HINT: system notice
// DeleteUser completely and permanently deletes everything of user. // DeleteUser completely and permanently deletes everything of user.
func DeleteUser(u *User) error { func DeleteUser(u *User) error {
// Check ownership of repository. // Check ownership of repository.
@ -390,13 +390,13 @@ func DeleteUser(u *User) error {
// Check membership of organization. // Check membership of organization.
count, err = u.GetOrganizationCount() count, err = u.GetOrganizationCount()
if err != nil { if err != nil {
return errors.New("modesl.GetRepositories(GetOrganizationCount): " + err.Error()) return errors.New("GetOrganizationCount: " + err.Error())
} else if count > 0 { } else if count > 0 {
return ErrUserHasOrgs return ErrUserHasOrgs
} }
// TODO: check issues, other repos' commits // FIXME: check issues, other repos' commits
// TODO: roll backable in some point. // FIXME: roll backable in some point.
// Delete all followers. // Delete all followers.
if _, err = x.Delete(&Follow{FollowId: u.Id}); err != nil { if _, err = x.Delete(&Follow{FollowId: u.Id}); err != nil {

3
routers/admin/users.go

@ -220,6 +220,9 @@ func DeleteUser(ctx *middleware.Context) {
case models.ErrUserOwnRepos: case models.ErrUserOwnRepos:
ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo")) ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo"))
ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid"))
case models.ErrUserHasOrgs:
ctx.Flash.Error(ctx.Tr("admin.users.still_has_org"))
ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid"))
default: default:
ctx.Handle(500, "DeleteUser", err) ctx.Handle(500, "DeleteUser", err)
} }

3
routers/user/setting.go

@ -311,6 +311,9 @@ func SettingsDelete(ctx *middleware.Context) {
case models.ErrUserOwnRepos: case models.ErrUserOwnRepos:
ctx.Flash.Error(ctx.Tr("form.still_own_repo")) ctx.Flash.Error(ctx.Tr("form.still_own_repo"))
ctx.Redirect(setting.AppSubUrl + "/user/settings/delete") ctx.Redirect(setting.AppSubUrl + "/user/settings/delete")
case models.ErrUserHasOrgs:
ctx.Flash.Error(ctx.Tr("form.still_has_org"))
ctx.Redirect(setting.AppSubUrl + "/user/settings/delete")
default: default:
ctx.Handle(500, "DeleteUser", err) ctx.Handle(500, "DeleteUser", err)
} }

Loading…
Cancel
Save