fixed visiting project details for a admin user.

This commit is contained in:
wknet123 2016-03-07 17:59:47 +08:00
parent 3b71580986
commit 61240f9144
2 changed files with 13 additions and 3 deletions

View File

@ -64,6 +64,8 @@ func (idc *ItemDetailController) Get() {
if sessionUserID != nil {
userId := sessionUserID.(int)
idc.Data["Username"] = idc.GetSession("username")
idc.Data["UserId"] = sessionUserID.(int)
@ -73,12 +75,20 @@ func (idc *ItemDetailController) Get() {
idc.CustomAbort(http.StatusInternalServerError, "Internal error.")
}
if project.Public == 0 && len(roleList) == 0 {
isAdmin, err := dao.IsAdminRole(userId)
if err != nil {
beego.Error("Error occurred in IsAdminRole:", err)
idc.CustomAbort(http.StatusInternalServerError, "Internal error.")
}
if !isAdmin && (project.Public == 0 && len(roleList) == 0) {
idc.Redirect("/registry/project", http.StatusFound)
return
}
if len(roleList) > 0 {
if isAdmin {
idc.Data["RoleId"] = models.SYSADMIN
} else if len(roleList) > 0 {
idc.Data["RoleId"] = roleList[0].RoleID
}
}

View File

@ -152,7 +152,7 @@ jQuery(function(){
url: "/api/projects/" + $("#projectId").val() + "/members/current",
type: "get",
success: function(data, status, xhr){
if(xhr && xhr.status == 200 && data.roles.length > 0){
if(xhr && xhr.status == 200 && data.roles != null && data.roles.length > 0){
hasAuthorization = true;
}
}