added start of set user permissions
This commit is contained in:
parent
01eedc6246
commit
5dd87d8319
@ -76,9 +76,28 @@ func (con Connection) InviteUser(c *gin.Context) {
|
|||||||
c.JSON(200, "OK")
|
c.JSON(200, "OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SetUserPermissionsRequest struct {
|
||||||
|
Permissions models.Permission
|
||||||
|
}
|
||||||
|
|
||||||
|
func (con Connection) SetUserPermissions(c *gin.Context) {
|
||||||
|
var request InviteUser
|
||||||
|
json.NewDecoder(c.Request.Body).Decode(&request)
|
||||||
|
token := uuid.NewString()
|
||||||
|
|
||||||
|
err := mail.SendMail(request.Email, "You've been invited to join", "please open this link https://games.acooldomain.co/signup?token="+token)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithError(500, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
con.connection.Database("Backend").Collection("Users").UpdateOne(context.TODO(), , bson.D{{Key}})
|
||||||
|
c.JSON(200, "OK")
|
||||||
|
}
|
||||||
|
|
||||||
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.GET("/@me", auth.AuthorizedTo(0), connection.GetUser)
|
||||||
group.POST("/", auth.AuthorizedTo(models.Admin), connection.InviteUser)
|
group.POST("/", auth.AuthorizedTo(models.Admin), connection.InviteUser)
|
||||||
|
group.PATCH("/:user_id/permissions", auth.AuthorizedTo(models.Admin), connection.SetUserPermissions)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user