work on adding group support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
type RegisterInput struct {
|
||||
type AddUserInput struct {
|
||||
UserName string `json:"userName" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
GroupId int `json:"groupId"`
|
||||
@@ -73,8 +73,8 @@ func DeleteUser(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func RegisterUser(c *gin.Context) {
|
||||
var input RegisterInput
|
||||
func AddUser(c *gin.Context) {
|
||||
var input AddUserInput
|
||||
|
||||
if err := c.ShouldBindJSON(&input); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
|
34
controllers/controlGroups.go
Normal file
34
controllers/controlGroups.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"smt/models"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type AddGroupInput struct {
|
||||
GroupName string `db:"GroupName" json:"groupName"`
|
||||
LdapGroup bool `db:"LdapGroup" json:"ldapGroup"`
|
||||
LdapDn string `db:"LdapDN" json:"ldapDn"`
|
||||
Admin bool `db:"Admin" json:"admin"`
|
||||
}
|
||||
|
||||
func GetGroups(c *gin.Context) {
|
||||
groups, err := models.GroupList()
|
||||
|
||||
if err != nil {
|
||||
errString := fmt.Sprintf("error retrieving groups : '%s'", err)
|
||||
log.Printf("GetGroups %s\n", errString)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": errString})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "success", "data": groups})
|
||||
}
|
||||
|
||||
func AddGroup(c *gin.Context) {
|
||||
|
||||
}
|
Reference in New Issue
Block a user