|
@@ -55,12 +55,10 @@ func (this *Engine) Process() bool {
|
|
|
|
|
|
// Display MySQL install page on backend
|
|
|
if this.Wrap.IsBackend && !this.Wrap.ConfMysqlExists {
|
|
|
- // Redirect to main url if needs
|
|
|
- if this.Wrap.R.URL.Path != "/cp/" {
|
|
|
- http.Redirect(this.Wrap.W, this.Wrap.R, "/cp/"+utils.ExtractGetParams(this.Wrap.R.RequestURI), 302)
|
|
|
+ // Redirect
|
|
|
+ if this.redirectToCP() {
|
|
|
return true
|
|
|
}
|
|
|
-
|
|
|
// Show mysql settings form
|
|
|
utils.SystemRenderTemplate(this.Wrap.W, assets.TmplCpMySql, nil)
|
|
|
return true
|
|
@@ -98,12 +96,10 @@ func (this *Engine) Process() bool {
|
|
|
return true
|
|
|
}
|
|
|
if count <= 0 {
|
|
|
- // Redirect to main url if needs
|
|
|
- if this.Wrap.R.URL.Path != "/cp/" {
|
|
|
- http.Redirect(this.Wrap.W, this.Wrap.R, "/cp/"+utils.ExtractGetParams(this.Wrap.R.RequestURI), 302)
|
|
|
+ // Redirect
|
|
|
+ if this.redirectToCP() {
|
|
|
return true
|
|
|
}
|
|
|
-
|
|
|
// Show first user form
|
|
|
utils.SystemRenderTemplate(this.Wrap.W, assets.TmplCpFirstUser, nil)
|
|
|
return true
|
|
@@ -112,12 +108,10 @@ func (this *Engine) Process() bool {
|
|
|
|
|
|
// Show login page if need
|
|
|
if this.Wrap.S.GetInt("UserId", 0) <= 0 {
|
|
|
- // Redirect to main url if needs
|
|
|
- if this.Wrap.R.URL.Path != "/cp/" {
|
|
|
- http.Redirect(this.Wrap.W, this.Wrap.R, "/cp/"+utils.ExtractGetParams(this.Wrap.R.RequestURI), 302)
|
|
|
+ // Redirect
|
|
|
+ if this.redirectToCP() {
|
|
|
return true
|
|
|
}
|
|
|
-
|
|
|
// Show login form
|
|
|
utils.SystemRenderTemplate(this.Wrap.W, assets.TmplCpLogin, nil)
|
|
|
return true
|
|
@@ -131,12 +125,10 @@ func (this *Engine) Process() bool {
|
|
|
|
|
|
// Only active admins can use backend
|
|
|
if !(this.Wrap.User.A_admin == 1 && this.Wrap.User.A_active == 1) {
|
|
|
- // Redirect to main url if needs
|
|
|
- if this.Wrap.R.URL.Path != "/cp/" {
|
|
|
- http.Redirect(this.Wrap.W, this.Wrap.R, "/cp/"+utils.ExtractGetParams(this.Wrap.R.RequestURI), 302)
|
|
|
+ // Redirect
|
|
|
+ if this.redirectToCP() {
|
|
|
return true
|
|
|
}
|
|
|
-
|
|
|
// Show login form
|
|
|
utils.SystemRenderTemplate(this.Wrap.W, assets.TmplCpLogin, nil)
|
|
|
return true
|
|
@@ -145,3 +137,11 @@ func (this *Engine) Process() bool {
|
|
|
// Render backend
|
|
|
return this.Mods.XXXBackEnd(this.Wrap)
|
|
|
}
|
|
|
+
|
|
|
+func (this *Engine) redirectToCP() bool {
|
|
|
+ if this.Wrap.R.URL.Path != "/cp/" {
|
|
|
+ http.Redirect(this.Wrap.W, this.Wrap.R, "/cp/"+utils.ExtractGetParams(this.Wrap.R.RequestURI), 302)
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|