fixed api
This commit is contained in:
@@ -34,6 +34,25 @@ func (con Connection) GetUsers(c *gin.Context) {
|
||||
c.IndentedJSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
type UserResponse struct {
|
||||
Username string
|
||||
Permissions models.Permission
|
||||
Email string
|
||||
}
|
||||
|
||||
func (con Connection) GetUser(c *gin.Context) {
|
||||
claims, exists := c.Get("claims")
|
||||
if !exists {
|
||||
c.AbortWithStatus(505)
|
||||
return
|
||||
}
|
||||
|
||||
c.IndentedJSON(http.StatusOK, UserResponse{
|
||||
Username: claims.(*auth.AuthClaims).Username,
|
||||
Permissions: claims.(*auth.AuthClaims).Permissions,
|
||||
})
|
||||
}
|
||||
|
||||
type InviteUser struct {
|
||||
Email string `json:"Email"`
|
||||
Permissions models.Permission `json:"Permissions"`
|
||||
@@ -60,5 +79,6 @@ func (con Connection) InviteUser(c *gin.Context) {
|
||||
func LoadGroup(group *gin.RouterGroup, client *mongo.Client, config models.GlobalConfig) {
|
||||
connection := Connection{connection: client}
|
||||
group.GET("/", auth.AuthorizedTo(0), connection.GetUsers)
|
||||
group.GET("/@me", auth.AuthorizedTo(0), connection.GetUser)
|
||||
group.POST("/", auth.AuthorizedTo(models.Admin), connection.InviteUser)
|
||||
}
|
||||
|
Reference in New Issue
Block a user