Skip to content

Commit

Permalink
update user permission
Browse files Browse the repository at this point in the history
  • Loading branch information
3xxx committed Jul 24, 2021
1 parent 1bb8c4e commit eb1c593
Show file tree
Hide file tree
Showing 23 changed files with 219 additions and 159 deletions.
8 changes: 4 additions & 4 deletions controllers/AccountController.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (c *AccountController) Login() {
if u == "" {
u = conf.URLFor("HomeController.Index")
}
c.Redirect(u, 301)
c.Redirect(u, 302)
}
var remember CookieRemember
// 如果 Cookie 中存在登录信息
Expand Down Expand Up @@ -138,7 +138,7 @@ func (c *AccountController) LoggedIn(isPost bool) interface{} {
turl := c.referer()

if !isPost {
c.Redirect(turl, 301)
c.Redirect(turl, 302)
return nil
} else {
var data struct {
Expand All @@ -155,7 +155,7 @@ func (c *AccountController) Register() {

//如果用户登录了,则跳转到网站首页
if member, ok := c.GetSession(conf.LoginSessionName).(models.Member); ok && member.MemberId > 0 {
c.Redirect(conf.URLFor("HomeController.Index"), 301)
c.Redirect(conf.URLFor("HomeController.Index"), 302)
}
// 如果没有开启用户注册
if v, ok := c.Option["ENABLED_REGISTER"]; ok && !strings.EqualFold(v, "true") {
Expand Down Expand Up @@ -431,7 +431,7 @@ func (c *AccountController) Logout() {

u := c.Ctx.Request.Header.Get("Referer")

c.Redirect(conf.URLFor("AccountController.Login", "url", u), 301)
c.Redirect(conf.URLFor("AccountController.Login", "url", u), 302)
}

// 验证码
Expand Down
2 changes: 1 addition & 1 deletion controllers/BlogController.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type BlogController struct {
func (c *BlogController) Prepare() {
c.MindocBaseController.Prepare()
if !c.EnableAnonymous && c.Member == nil {
c.Redirect(conf.URLFor("AccountController.Login")+"?url="+url.PathEscape(conf.BaseUrl+c.Ctx.Request.URL.RequestURI()), 301)
c.Redirect(conf.URLFor("AccountController.Login")+"?url="+url.PathEscape(conf.BaseUrl+c.Ctx.Request.URL.RequestURI()), 302)
}
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/DocumentController.go
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,6 @@ func promptUserToLogIn(c *DocumentController) {
if c.IsAjax() {
c.JsonResult(6000, "请重新登录。")
} else {
c.Redirect(conf.URLFor("AccountController.Login")+"?url="+url.PathEscape(conf.BaseUrl+c.Ctx.Request.URL.RequestURI()), 301)
c.Redirect(conf.URLFor("AccountController.Login")+"?url="+url.PathEscape(conf.BaseUrl+c.Ctx.Request.URL.RequestURI()), 302)
}
}
2 changes: 1 addition & 1 deletion controllers/HomeController.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (c *HomeController) Prepare() {
c.MindocBaseController.Prepare()
//如果没有开启匿名访问,则跳转到登录页面
if !c.EnableAnonymous && c.Member == nil {
c.Redirect(conf.URLFor("AccountController.Login")+"?url="+url.PathEscape(conf.BaseUrl+c.Ctx.Request.URL.RequestURI()), 301)
c.Redirect(conf.URLFor("AccountController.Login")+"?url="+url.PathEscape(conf.BaseUrl+c.Ctx.Request.URL.RequestURI()), 302)
}
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/SearchController.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (c *MindocSearchController) Index() {

//如果没有开启你们访问则跳转到登录
if !c.EnableAnonymous && c.Member == nil {
c.Redirect(conf.URLFor("AccountController.Login"), 301)
c.Redirect(conf.URLFor("AccountController.Login"), 302)
return
}

Expand Down
26 changes: 13 additions & 13 deletions controllers/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -1744,8 +1744,8 @@ func (c *ArticleController) AddArticle() {
// } else {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr", 301)
// c.Redirect("/roleerr?url="+route, 302)
// c.Redirect("/roleerr", 302)
// return
// }
}
Expand Down Expand Up @@ -2367,8 +2367,8 @@ func (c *ArticleController) AddProdArticle() {
if !islogin {
route := c.Ctx.Request.URL.String()
c.Data["Url"] = route
c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr", 301)
c.Redirect("/roleerr?url="+route, 302)
// c.Redirect("/roleerr", 302)
return
}
pid := c.Input().Get("pid")
Expand All @@ -2390,8 +2390,8 @@ func (c *ArticleController) AddProdArticle() {
// } else {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// // c.Redirect("/roleerr", 301)
// c.Redirect("/roleerr?url="+route, 302)
// // c.Redirect("/roleerr", 302)
// return
// }
}
Expand All @@ -2402,8 +2402,8 @@ func (c *ArticleController) ModifyArticle() {
// if !isadmin {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// // c.Redirect("/roleerr", 301)
// c.Redirect("/roleerr?url="+route, 302)
// // c.Redirect("/roleerr", 302)
// return
// }
//这里再添加一次验证才行!!!
Expand Down Expand Up @@ -2453,13 +2453,13 @@ func (c *ArticleController) UpdateArticle() {
} else {
c.Data["json"] = "ok"
c.ServeJSON()
// c.Redirect("/project/product/article/"+pid, 301) //回到修改后的文章
// c.Redirect("/project/product/article/"+pid, 302) //回到修改后的文章
}
// } else {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// // c.Redirect("/roleerr", 301)
// c.Redirect("/roleerr?url="+route, 302)
// // c.Redirect("/roleerr", 302)
// return
// }
}
Expand All @@ -2486,8 +2486,8 @@ func (c *ArticleController) DeleteArticle() {
} else {
route := c.Ctx.Request.URL.String()
c.Data["Url"] = route
c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr", 301)
c.Redirect("/roleerr?url="+route, 302)
// c.Redirect("/roleerr", 302)
return
}
}
Expand Down
48 changes: 24 additions & 24 deletions controllers/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func (c *AttachController) AddAttachment() {
if !isLogin {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr?url="+route, 302)
c.Data["json"] = "未登陆"
c.ServeJSON()
return
Expand Down Expand Up @@ -642,12 +642,12 @@ func (c *AttachController) AddAttachment() {
// } else {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr", 301)
// c.Redirect("/roleerr?url="+route, 302)
// c.Redirect("/roleerr", 302)
// return
// }
// c.TplName = "topic_one_add.tpl" //不加这句上传出错,虽然可以成功上传
// c.Redirect("/topic", 301)
// c.Redirect("/topic", 302)
// success : 0 | 1, // 0 表示上传失败,1 表示上传成功
// message : "提示的信息,上传成功或上传失败及错误信息等。",
// url : "图片地址" // 上传成功时才返回
Expand Down Expand Up @@ -946,7 +946,7 @@ func (c *AttachController) AddAttachment2() {
if !isLogin {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr?url="+route, 302)
c.Data["json"] = "未登陆"
c.ServeJSON()
return
Expand Down Expand Up @@ -1226,8 +1226,8 @@ func (c *AttachController) UpdateAttachment() {
// } else {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// // c.Redirect("/roleerr", 301)
// c.Redirect("/roleerr?url="+route, 302)
// // c.Redirect("/roleerr", 302)
// return
// }
}
Expand All @@ -1238,7 +1238,7 @@ func (c *AttachController) DeleteAttachment() {
if !isLogin {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr?url="+route, 302)
c.Data["json"] = "未登陆"
c.ServeJSON()
return
Expand Down Expand Up @@ -1340,8 +1340,8 @@ func (c *AttachController) DeleteAttachment() {
// } else {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// // c.Redirect("/roleerr", 301)
// c.Redirect("/roleerr?url="+route, 302)
// // c.Redirect("/roleerr", 302)
// return
// }
}
Expand Down Expand Up @@ -1392,7 +1392,7 @@ func (c *AttachController) DownloadAttachment() {
if !isLogin {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr?url="+route, 302)
c.Data["json"] = "未登陆"
c.ServeJSON()
return
Expand Down Expand Up @@ -1493,7 +1493,7 @@ func (c *AttachController) DownloadAttachment() {
} else {
route := c.Ctx.Request.URL.String()
c.Data["Url"] = route
c.Redirect("/roleerr?url="+route, 301)
c.Redirect("/roleerr?url="+route, 302)
return
}
// case ".dwg", ".DWG": //保留,dwg在线阅览模式!!!!
Expand All @@ -1512,22 +1512,22 @@ func (c *AttachController) DownloadAttachment() {
// } else {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr?url="+route, 302)
// return
// }
default:
if e.Enforce(useridstring, projurl, c.Ctx.Request.Method, fileext) || isadmin || isme {
// http.ServeFile(c.Ctx.ResponseWriter, c.Ctx.Request, filePath)//这样写下载的文件名称不对
// c.Redirect(url+"/"+attachment.FileName, 301)
// c.Redirect(url+"/"+attachment.FileName, 302)
c.Ctx.Output.Download(fileurl + "/" + attachment.FileName)
// beego.Info("下载……" + fileurl + "/" + attachment.FileName)
utils.FileLogs.Info(username + " " + "download" + " " + fileurl + "/" + attachment.FileName)
} else {
utils.FileLogs.Info(c.Ctx.Input.IP() + "want " + "download" + " " + fileurl + "/" + attachment.FileName)
route := c.Ctx.Request.URL.String()
c.Data["Url"] = route
c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr", 301)
c.Redirect("/roleerr?url="+route, 302)
// c.Redirect("/roleerr", 302)
return
}
}
Expand Down Expand Up @@ -1602,7 +1602,7 @@ func (c *AttachController) Attachment() {
// beego.Info(!islogin)
route := c.Ctx.Request.URL.String()
c.Data["Url"] = route
c.Redirect("/roleerr?url="+route, 301)
c.Redirect("/roleerr?url="+route, 302)
return
} else {
http.ServeFile(c.Ctx.ResponseWriter, c.Ctx.Request, filePath)
Expand Down Expand Up @@ -1685,14 +1685,14 @@ func (c *AttachController) Attachment() {
if e.Enforce(useridstring, projurls+"/", c.Ctx.Request.Method, fileext) || isadmin || isme {
http.ServeFile(c.Ctx.ResponseWriter, c.Ctx.Request, filePath) //这样写下载的文件名称不对
// beego.Info(isadmin)
// c.Redirect(url+"/"+attachment.FileName, 301)
// c.Redirect(url+"/"+attachment.FileName, 302)
// c.Ctx.Output.Download(fileurl + "/" + attachment.FileName)
} else {
// beego.Info(useridstring)
route := c.Ctx.Request.URL.String()
c.Data["Url"] = route
c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr", 301)
c.Redirect("/roleerr?url="+route, 302)
// c.Redirect("/roleerr", 302)
return
}
}
Expand All @@ -1703,7 +1703,7 @@ func (c *AttachController) Attachment() {
// } else {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr?url="+route, 302)
// return
// }
// default:
Expand All @@ -1712,7 +1712,7 @@ func (c *AttachController) Attachment() {
// } else {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr?url="+route, 302)
// return
// }
// }
Expand Down Expand Up @@ -1848,7 +1848,7 @@ func (c *AttachController) Pdf() {
if uid == 0 {
route := c.Ctx.Request.URL.String()
c.Data["Url"] = route
c.Redirect("/roleerr?url="+route, 301)
c.Redirect("/roleerr?url="+route, 302)
return
}

Expand Down Expand Up @@ -1935,7 +1935,7 @@ func (c *AttachController) Pdf() {
break
}
}
c.Redirect("/pdf?p="+p1+"&id="+strconv.FormatInt(projid, 10), 301)
c.Redirect("/pdf?p="+p1+"&id="+strconv.FormatInt(projid, 10), 302)
} else {
PdfLink := Url + "/" + Attachments[pNum-1].FileName
// beego.Info(PdfLink)
Expand Down
2 changes: 1 addition & 1 deletion controllers/business_trip.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (c *BusinessController) AddBusiness() {
// if !isLogin {
// route := c.Ctx.Request.URL.String()
// c.Data["Url"] = route
// c.Redirect("/roleerr?url="+route, 301)
// c.Redirect("/roleerr?url="+route, 302)
// c.Data["json"] = "未登陆"
// c.ServeJSON()
// return
Expand Down
4 changes: 2 additions & 2 deletions controllers/flv.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func (c *FlvController) GetFlvList() {
token := c.Input().Get("token")
site := c.Ctx.Input.Site() + ":" + strconv.Itoa(c.Ctx.Input.Port())
if token == "" {
// c.Redirect("http://localhost:8080/v1/sso/ssologin?service="+site+c.Ctx.Request.URL.String()+"token="+token, 301)
// c.Redirect("http://localhost:8080/v1/sso/ssologin?service="+site+c.Ctx.Request.URL.String()+"token="+token, 302)
// } else {
token = c.Ctx.GetCookie("token")
//
}
username, err := utils.CheckToken(token)
beego.Info(username)
if err != nil {
c.Redirect("http://localhost:8080/v1/sso/ssologin?service="+site+c.Ctx.Request.URL.String(), 301)
c.Redirect("http://localhost:8080/v1/sso/ssologin?service="+site+c.Ctx.Request.URL.String(), 302)
} else {
c.Ctx.SetCookie("token", token, "3600", "/")
}
Expand Down
Loading

0 comments on commit eb1c593

Please sign in to comment.