Big Backend Refatoring: Renamed Account -> Org

This commit is contained in:
Torkel Ödegaard
2015-02-23 20:07:49 +01:00
parent e9e2fa2927
commit 26e4809e2e
43 changed files with 774 additions and 773 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ func RoleAuth(roles ...m.RoleType) macaron.Handler {
return func(c *Context) {
ok := false
for _, role := range roles {
if role == c.AccountRole {
if role == c.OrgRole {
ok = true
break
}
+9 -8
View File
@@ -56,22 +56,23 @@ func GetContextHandler() macaron.Handler {
ctx.SignedInUser = &m.SignedInUser{}
// TODO: fix this
ctx.AccountRole = keyInfo.Role
ctx.OrgRole = keyInfo.Role
ctx.ApiKeyId = keyInfo.Id
ctx.AccountId = keyInfo.AccountId
ctx.OrgId = keyInfo.OrgId
}
} else if setting.AnonymousEnabled {
accountQuery := m.GetAccountByNameQuery{Name: setting.AnonymousAccountName}
if err := bus.Dispatch(&accountQuery); err != nil {
if err == m.ErrAccountNotFound {
log.Error(3, "Anonymous access account name does not exist", nil)
orgQuery := m.GetOrgByNameQuery{Name: setting.AnonymousOrgName}
if err := bus.Dispatch(&orgQuery); err != nil {
if err == m.ErrOrgNotFound {
log.Error(3, "Anonymous access organization name does not exist", nil)
}
} else {
ctx.IsSignedIn = false
ctx.HasAnonymousAccess = true
ctx.SignedInUser = &m.SignedInUser{}
ctx.AccountRole = m.RoleType(setting.AnonymousAccountRole)
ctx.AccountId = accountQuery.Result.Id
ctx.OrgRole = m.RoleType(setting.AnonymousOrgRole)
ctx.OrgId = orgQuery.Result.Id
ctx.OrgName = orgQuery.Result.Name
}
}