Browse Source

Remove first user page from control panel

Vova Tkach 6 years ago
parent
commit
e827a30c62

+ 0 - 1
.gitignore

@@ -31,7 +31,6 @@
 /hosts/localhost/config/mysql.json
 
 # All else
-/hosts/localhost/config/.installed
 /hosts/localhost/config/config.json
 
 # Skip cypress libs folder

+ 0 - 3
assets/tmpl.cp.first.user.go

@@ -1,3 +0,0 @@
-package assets
-
-var TmplCpFirstUser = []byte(`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="theme-color" content="#205081" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>Creating first user</title><link rel="stylesheet" href="{{$.System.PathCssBootstrap}}"><link rel="stylesheet" href="{{$.System.PathCssCpStyles}}"><link rel="shortcut icon" href="{{$.System.PathIcoFav}}" type="image/x-icon" /><style type="text/css">html{height:100%;}</style></head><body class="cp-first-user text-center"><form class="form-signin card" action="/cp/" method="post"><input type="hidden" name="action" value="index-first-user"><h1 class="h3 mb-3 font-weight-normal">Creating first user</h1><label for="first_name" class="sr-only">User first name</label><input type="text" id="first_name" name="first_name" class="form-control mb-3" placeholder="User first name"><label for="last_name" class="sr-only">User last name</label><input type="text" id="last_name" name="last_name" class="form-control mb-3" placeholder="User last name"><label for="email" class="sr-only">User email</label><input type="email" id="email" name="email" class="form-control mb-3" placeholder="User email" required><label for="password" class="sr-only">User password</label><input type="password" id="password" name="password" class="form-control mb-3" placeholder="User password" required><div class="sys-messages"></div><button class="btn btn-lg btn-primary btn-block" type="submit">Create</button></form><script src="{{$.System.PathJsJquery}}"></script><script src="{{$.System.PathJsPopper}}"></script><script src="{{$.System.PathJsBootstrap}}"></script><script src="{{$.System.PathJsCpScripts}}"></script></body></html>`)

+ 0 - 33
assets/tmpl.cp.first.user.html

@@ -1,33 +0,0 @@
-<!doctype html>
-<html lang="en">
-	<head>
-		<meta charset="utf-8">
-		<meta name="theme-color" content="#205081" />
-		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
-		<title>Creating first user</title>
-		<link rel="stylesheet" href="{{$.System.PathCssBootstrap}}">
-		<link rel="stylesheet" href="{{$.System.PathCssCpStyles}}">
-		<link rel="shortcut icon" href="{{$.System.PathIcoFav}}" type="image/x-icon" />
-		<style type="text/css">html{height:100%;}</style>
-	</head>
-	<body class="cp-first-user text-center">
-		<form class="form-signin card" action="/cp/" method="post">
-			<input type="hidden" name="action" value="index-first-user">
-			<h1 class="h3 mb-3 font-weight-normal">Creating first user</h1>
-			<label for="first_name" class="sr-only">User first name</label>
-			<input type="text" id="first_name" name="first_name" class="form-control mb-3" placeholder="User first name">
-			<label for="last_name" class="sr-only">User last name</label>
-			<input type="text" id="last_name" name="last_name" class="form-control mb-3" placeholder="User last name">
-			<label for="email" class="sr-only">User email</label>
-			<input type="email" id="email" name="email" class="form-control mb-3" placeholder="User email" required>
-			<label for="password" class="sr-only">User password</label>
-			<input type="password" id="password" name="password" class="form-control mb-3" placeholder="User password" required>
-			<div class="sys-messages"></div>
-			<button class="btn btn-lg btn-primary btn-block" type="submit">Create</button>
-		</form>
-		<script src="{{$.System.PathJsJquery}}"></script>
-		<script src="{{$.System.PathJsPopper}}"></script>
-		<script src="{{$.System.PathJsBootstrap}}"></script>
-		<script src="{{$.System.PathJsCpScripts}}"></script>
-	</body>
-</html>

+ 0 - 32
engine/engine.go

@@ -73,38 +73,6 @@ func (this *Engine) Process() bool {
 		return true
 	}
 
-	// Show add first user form if no any user in database
-	if !utils.IsFileExists(this.Wrap.DConfig + string(os.PathSeparator) + ".installed") {
-		var count int
-		err = this.Wrap.DB.QueryRow(`
-			SELECT
-				COUNT(*)
-			FROM
-				users
-			;`,
-		).Scan(
-			&count,
-		)
-		if err != nil {
-			utils.SystemErrorPageEngine(this.Wrap.W, err)
-			return true
-		}
-		if count <= 0 {
-			// Redirect
-			if this.redirectFixCpUrl() {
-				return true
-			}
-			// Show first user form
-			utils.SystemRenderTemplate(this.Wrap.W, assets.TmplCpFirstUser, nil)
-			return true
-		} else {
-			// Mark what one or more users already exists
-			if _, err := os.OpenFile(this.Wrap.DConfig+string(os.PathSeparator)+".installed", os.O_RDONLY|os.O_CREATE, 0666); err != nil {
-				this.Wrap.LogError(err.Error())
-			}
-		}
-	}
-
 	// Show login page if need
 	if this.Wrap.S.GetInt("UserId", 0) <= 0 {
 		// Redirect

+ 0 - 0
hosts/localhost/config/.installed


+ 0 - 1
modules/module_index_act_cypress.go

@@ -30,7 +30,6 @@ func (this *Modules) RegisterAction_IndexCypressReset() *Action {
 			return
 		}
 
-		os.Remove(wrap.DConfig + string(os.PathSeparator) + ".installed")
 		os.Remove(wrap.DConfig + string(os.PathSeparator) + "mysql.json")
 		os.Remove(wrap.DConfig + string(os.PathSeparator) + "config.json")