From 3a616b0b5ee064f4419db8b7c3ec4905f1d46609 Mon Sep 17 00:00:00 2001 From: Lukas Bachschwell Date: Mon, 12 Nov 2018 11:43:14 +0100 Subject: [PATCH] Some additions --- Readme.md | 7 +++++++ controllers/auth.go | 2 +- services/companydb/companydb.go | 15 ++++++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 2347e86..2e51852 100644 --- a/Readme.md +++ b/Readme.md @@ -19,3 +19,10 @@ To regenerate docs simply run `bee generate docs` ## Notes: - Fixes have been placed into the beego orm for setting the timezone when using NewOrmWithDB() + +## Management tools + +- create databases, +- run different migrations on template and system +- run migrations on all company tables (list, connect, migrate) +- generate password diff --git a/controllers/auth.go b/controllers/auth.go index 9ef4bce..7fb680a 100644 --- a/controllers/auth.go +++ b/controllers/auth.go @@ -81,7 +81,7 @@ func (c *AuthController) Login() { return } - if password != userCompanyMapping.PasswordHash { // TODO: Hash me + if !tokenTools.CheckPasswordHash(password, userCompanyMapping.PasswordHash) { c.ServeJSONError("Email/Password incorrect") return } diff --git a/services/companydb/companydb.go b/services/companydb/companydb.go index 2777929..b49b7df 100644 --- a/services/companydb/companydb.go +++ b/services/companydb/companydb.go @@ -77,14 +77,19 @@ func GetDatabase(tokenString string) (jwt.MapClaims, *sql.DB, error) { } // CreateDatabase Create a database by copying the template -func CreateDatabase(token string) { +func CreateDatabase(companyName string) { /* - db, err = sql.Open("postgres", "host=127.0.0.1 port=5435 user=postgres password=postgre dbname=company5 sslmode=disable") - if err != nil { - log.Fatal(err) + if dbs[companyName] != nil { + fmt.Println("DB Already open") + return dbs[companyName], nil } + /* + db, err = sql.Open("postgres", "host=127.0.0.1 port=5435 user=postgres password=postgre dbname=company5 sslmode=disable") + if err != nil { + log.Fatal(err) + } - or, err := orm.NewOrmWithDB("postgres", "temp", db) + or, err := orm.NewOrmWithDB("postgres", "temp", db) */ }