This commit is contained in:
@@ -25,7 +25,8 @@ const createRoles string = `
|
|||||||
RoleId INTEGER PRIMARY KEY ASC,
|
RoleId INTEGER PRIMARY KEY ASC,
|
||||||
RoleName VARCHAR,
|
RoleName VARCHAR,
|
||||||
ReadOnly BOOLEAN,
|
ReadOnly BOOLEAN,
|
||||||
Admin BOOLEAN
|
Admin BOOLEAN,
|
||||||
|
LdapGroup VARCHAR
|
||||||
);
|
);
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -96,15 +97,15 @@ func CreateTables() {
|
|||||||
}
|
}
|
||||||
rowCount, _ = CheckCount("roles")
|
rowCount, _ = CheckCount("roles")
|
||||||
if rowCount == 0 {
|
if rowCount == 0 {
|
||||||
if _, err = db.Exec("INSERT INTO roles VALUES(1, 'Admin', false, true);"); err != nil {
|
if _, err = db.Exec("INSERT INTO roles VALUES(1, 'Admin', false, true, '');"); err != nil {
|
||||||
log.Printf("Error adding initial admin role : '%s'", err)
|
log.Printf("Error adding initial admin role : '%s'", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if _, err = db.Exec("INSERT INTO roles VALUES(2, 'UserRole', false, false);"); err != nil {
|
if _, err = db.Exec("INSERT INTO roles VALUES(2, 'UserRole', false, false, '');"); err != nil {
|
||||||
log.Printf("Error adding initial user role : '%s'", err)
|
log.Printf("Error adding initial user role : '%s'", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if _, err = db.Exec("INSERT INTO roles VALUES(3, 'GuestRole', true, false);"); err != nil {
|
if _, err = db.Exec("INSERT INTO roles VALUES(3, 'GuestRole', true, false, '');"); err != nil {
|
||||||
log.Printf("Error adding initial guest role : '%s'", err)
|
log.Printf("Error adding initial guest role : '%s'", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@@ -145,10 +146,23 @@ func CreateTables() {
|
|||||||
schemaCheck, _ := CheckColumnExists("schema", "Version")
|
schemaCheck, _ := CheckColumnExists("schema", "Version")
|
||||||
if !schemaCheck {
|
if !schemaCheck {
|
||||||
if _, err = db.Exec("INSERT INTO schema VALUES(1);"); err != nil {
|
if _, err = db.Exec("INSERT INTO schema VALUES(1);"); err != nil {
|
||||||
log.Printf("Error adding initial scehama version : '%s'", err)
|
log.Printf("Error adding initial schema version : '%s'", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Database updates added after initial version released
|
||||||
|
ldapCheck, _ := CheckColumnExists("roles", "LdapGroup")
|
||||||
|
|
||||||
|
if !ldapCheck {
|
||||||
|
// Add the column for LdapGroup in the roles table
|
||||||
|
_, err := db.Exec("ALTER TABLE roles ADD COLUMN LdapGroup VARCHAR;")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error altering roles table to add LdapGroup column : '%s'\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count the number of records in the sqlite database
|
// Count the number of records in the sqlite database
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"smt/utils/token"
|
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"smt/utils/token"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
UserId int `db:"UserId"`
|
UserId int `db:"UserId" json:"userId"`
|
||||||
RoleId int `db:"RoleId"`
|
RoleId int `db:"RoleId" json:"roleId"`
|
||||||
UserName string `db:"UserName"`
|
UserName string `db:"UserName" json:"userName"`
|
||||||
Password string `db:"Password" json:"-"`
|
Password string `db:"Password" json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user