diff --git a/README.md b/README.md
index b2e849a..d828b14 100644
--- a/README.md
+++ b/README.md
@@ -35,12 +35,14 @@ There are a couple options for getting Pogo up and running.
## Building
+_Note: [This requires a valid Go enviornment setup!](https://golang.org/doc/install)_
+
```
-# Clone the repository
-git clone https://github.com/gmemstr/pogo
+# Go get the repository
+go get github.com/gmemstr/pogo
# Go to directory
-cd pogo
+cd $GOPATH/src/github.com/gmemstr/pogo
# Get godep
go get github.com/tools/godep
diff --git a/admin/admin.go b/admin/admin.go
index 7dbb640..72fff1f 100644
--- a/admin/admin.go
+++ b/admin/admin.go
@@ -18,6 +18,7 @@ import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
+ "github.com/gorilla/mux"
"github.com/gmemstr/pogo/common"
)
@@ -169,6 +170,52 @@ func EditUser() common.Handler {
}
}
+func DeleteUser() common.Handler {
+
+ return func(rc *common.RouterContext, w http.ResponseWriter, r *http.Request) *common.HTTPError {
+
+ db, err := sql.Open("sqlite3", "assets/config/users.db")
+ if err != nil {
+ return &common.HTTPError{
+ Message: fmt.Sprintf("error opening sqlite3 file: %v", err),
+ StatusCode: http.StatusInternalServerError,
+ }
+ }
+ statement, err := db.Prepare("DELETE FROM users WHERE id=?")
+ if err != nil {
+ return &common.HTTPError{
+ Message: fmt.Sprintf("error preparing sqlite3 statement: %v", err),
+ StatusCode: http.StatusInternalServerError,
+ }
+ }
+
+ if err != nil {
+ return &common.HTTPError{
+ Message: err.Error(),
+ StatusCode: http.StatusBadRequest,
+ }
+ }
+ vars := mux.Vars(r)
+ id := vars["id"]
+ if id == "1" {
+ w.Write([]byte(""))
+ db.Close()
+ return nil
+ }
+
+ _, err = statement.Exec(id)
+ if err != nil {
+ return &common.HTTPError{
+ Message: fmt.Sprintf("error executing sqlite3 statement: %v", err),
+ StatusCode: http.StatusInternalServerError,
+ }
+ }
+ w.Write([]byte(""))
+ db.Close()
+ return nil
+ }
+}
+
func ListUsers() common.Handler {
return func(rc *common.RouterContext, w http.ResponseWriter, r *http.Request) *common.HTTPError {
diff --git a/assets/config/users.db b/assets/config/users.db
index ef24a39..ce23fae 100644
Binary files a/assets/config/users.db and b/assets/config/users.db differ
diff --git a/assets/web/static/app.js b/assets/web/static/app.js
index bf81fbd..c7be3ed 100644
--- a/assets/web/static/app.js
+++ b/assets/web/static/app.js
@@ -118,6 +118,7 @@ const useredit = {
+ Delete User
`,
data() {
diff --git a/router/router.go b/router/router.go
index 9fdaf72..0fe53aa 100644
--- a/router/router.go
+++ b/router/router.go
@@ -92,7 +92,10 @@ func Init() *mux.Router {
auth.RequireAuthorization(),
admin.AddUser(),
)).Methods("POST")
-
+ r.Handle("/admin/deleteuser/{id}", Handle(
+ auth.RequireAuthorization(),
+ admin.DeleteUser(),
+ )).Methods("GET")
r.Handle("/admin/edit", Handle(
auth.RequireAuthorization(),
admin.EditEpisode(),
diff --git a/webserver.go b/webserver.go
index 750df5d..5d3fc2e 100644
--- a/webserver.go
+++ b/webserver.go
@@ -23,6 +23,6 @@ func main() {
// Define routes
// We're live
r := router.Init()
- fmt.Println("Listening on port :3000")
+ fmt.Println("Your Pogo instance is live on port :3000")
log.Fatal(http.ListenAndServe(":3000", r))
}