fixed api
This commit is contained in:
parent
207ea01b4c
commit
cbe0d7934b
@ -150,8 +150,8 @@ func (con Connection) signUp(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SignInRequest struct {
|
type SignInRequest struct {
|
||||||
Username string `json:"username"`
|
Username string
|
||||||
Password string `json:"password"`
|
Password string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (con Connection) signIn(c *gin.Context) {
|
func (con Connection) signIn(c *gin.Context) {
|
||||||
@ -186,7 +186,7 @@ func (con Connection) signIn(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.SetCookie("auth", signedToken, -1, "", "", false, false)
|
c.SetCookie("auth", signedToken, -1, "", "", false, true)
|
||||||
c.IndentedJSON(http.StatusOK, signedToken)
|
c.IndentedJSON(http.StatusOK, signedToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,5 +793,5 @@ func LoadGroup(group *gin.RouterGroup, mongo_client *mongo.Client, config models
|
|||||||
group.GET("/:server_id/attach", auth.AuthorizedTo(models.RunCommand, connection.serverAuthorized(models.RunCommand)), connection.AttachServer)
|
group.GET("/:server_id/attach", auth.AuthorizedTo(models.RunCommand, connection.serverAuthorized(models.RunCommand)), connection.AttachServer)
|
||||||
group.PATCH("/:server_id", auth.AuthorizedTo(models.Admin, connection.serverAuthorized(models.Admin)), connection.UpdateServer)
|
group.PATCH("/:server_id", auth.AuthorizedTo(models.Admin, connection.serverAuthorized(models.Admin)), connection.UpdateServer)
|
||||||
group.POST("/:server_id/browse", auth.AuthorizedTo(models.Browse, connection.serverAuthorized(models.Admin)), connection.BrowseServer)
|
group.POST("/:server_id/browse", auth.AuthorizedTo(models.Browse, connection.serverAuthorized(models.Admin)), connection.BrowseServer)
|
||||||
group.POST("/:server_id/permissions", auth.AuthorizedTo(models.Browse, connection.serverAuthorized(models.Admin)), connection.GetServerUserPermissions)
|
group.GET("/:server_id/permissions", auth.AuthorizedTo(models.Browse, connection.serverAuthorized(models.Admin)), connection.GetServerUserPermissions)
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,25 @@ func (con Connection) GetUsers(c *gin.Context) {
|
|||||||
c.IndentedJSON(http.StatusOK, response)
|
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 {
|
type InviteUser struct {
|
||||||
Email string `json:"Email"`
|
Email string `json:"Email"`
|
||||||
Permissions models.Permission `json:"Permissions"`
|
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) {
|
func LoadGroup(group *gin.RouterGroup, client *mongo.Client, config models.GlobalConfig) {
|
||||||
connection := Connection{connection: client}
|
connection := Connection{connection: client}
|
||||||
group.GET("/", auth.AuthorizedTo(0), connection.GetUsers)
|
group.GET("/", auth.AuthorizedTo(0), connection.GetUsers)
|
||||||
|
group.GET("/@me", auth.AuthorizedTo(0), connection.GetUser)
|
||||||
group.POST("/", auth.AuthorizedTo(models.Admin), connection.InviteUser)
|
group.POST("/", auth.AuthorizedTo(models.Admin), connection.InviteUser)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user