change json key names
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-03 14:50:44 +11:00
parent 35583b5f86
commit f6602f2823
2 changed files with 23 additions and 9 deletions

View File

@@ -25,7 +25,8 @@ const createRoles string = `
RoleId INTEGER PRIMARY KEY ASC,
RoleName VARCHAR,
ReadOnly BOOLEAN,
Admin BOOLEAN
Admin BOOLEAN,
LdapGroup VARCHAR
);
`
@@ -96,15 +97,15 @@ func CreateTables() {
}
rowCount, _ = CheckCount("roles")
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)
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)
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)
os.Exit(1)
}
@@ -145,10 +146,23 @@ func CreateTables() {
schemaCheck, _ := CheckColumnExists("schema", "Version")
if !schemaCheck {
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)
}
}
// 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

View File

@@ -1,19 +1,19 @@
package models
import (
"smt/utils/token"
"errors"
"log"
"net/http"
"smt/utils/token"
"github.com/gin-gonic/gin"
"golang.org/x/crypto/bcrypt"
)
type User struct {
UserId int `db:"UserId"`
RoleId int `db:"RoleId"`
UserName string `db:"UserName"`
UserId int `db:"UserId" json:"userId"`
RoleId int `db:"RoleId" json:"roleId"`
UserName string `db:"UserName" json:"userName"`
Password string `db:"Password" json:"-"`
}