From 6b16c88f25f9cb688e9f9f1fcf132e446fd3ab86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Tikvi=C4=87?= Date: Wed, 31 May 2017 10:30:54 +0200 Subject: [PATCH] Working version with ora v4 --- auth_utility.go | 8 +++++++- json_utility.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/auth_utility.go b/auth_utility.go index 9ea6fca..5fedb16 100644 --- a/auth_utility.go +++ b/auth_utility.go @@ -22,11 +22,16 @@ const RoleAdmin string = "ADMINISTRATOR" const RoleManager string = "RUKOVODILAC" const RoleReporter string = "REPORTER" const RoleOperator string = "OPERATER" +const RoleAdminID uint32 = 1 +const RoleManagerID uint32 = 2 +const RoleReporterID uint32 = 3 +const RoleOperatorID uint32 = 4 // TokenClaims are JWT token claims. type TokenClaims struct { Username string `json:"username"` Role string `json:"role"` + RoleID uint32 `json:"roleID"` jwt.StandardClaims } @@ -85,7 +90,7 @@ func HashString(str string, presalt string) (hash, salt string, err error) { // CreateAPIToken returns JWT token with encoded username, role, expiration date and issuer claims. // It returns an error if it fails. -func CreateAPIToken(username, role string) (string, error) { +func CreateAPIToken(username, role string, roleID uint32) (string, error) { var apiToken string var err error @@ -96,6 +101,7 @@ func CreateAPIToken(username, role string) (string, error) { claims := TokenClaims{ username, role, + roleID, jwt.StandardClaims{ ExpiresAt: (time.Now().Add(OneWeek)).Unix(), Issuer: appName, diff --git a/json_utility.go b/json_utility.go index 4c47b69..757bb7d 100644 --- a/json_utility.go +++ b/json_utility.go @@ -161,7 +161,7 @@ func InitTables(db *ora.Ses, project string) error { // Returns an error if it fails. func fetchJSON(db *ora.Ses, project string) ([]byte, error) { db.SetCfg(db.Cfg().SetClob(ora.S)) - stmt, err := db.Prep(`SELECT JSON_CLOB FROM TABLES_CONFIG WHERE PROJEKAT` + EqualQuotes(project), ora.S) + stmt, err := db.Prep(`SELECT JSON_NCLOB FROM TABLES_CONFIG WHERE PROJEKAT` + EqualQuotes(project), ora.S) defer stmt.Close() if err != nil { return nil, err -- 1.8.1.2