workin oc-auth
This commit is contained in:
@@ -19,7 +19,8 @@ type GroupController struct {
|
||||
func (o *GroupController) Post() {
|
||||
// store and return Id or post with UUID
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
group, code, err := infrastructure.GetPermissionConnector().CreateGroup(id)
|
||||
clientID := ExtractClient(*o.Ctx.Request)
|
||||
group, code, err := infrastructure.GetPermissionConnector(clientID).CreateGroup(id)
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
@@ -44,7 +45,8 @@ func (o *GroupController) Post() {
|
||||
// @router /user/:id [get]
|
||||
func (o *GroupController) GetByUser() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
group, err := infrastructure.GetPermissionConnector().GetGroupByUser(id)
|
||||
clientID := ExtractClient(*o.Ctx.Request)
|
||||
group, err := infrastructure.GetPermissionConnector(clientID).GetGroupByUser(id)
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
@@ -67,7 +69,8 @@ func (o *GroupController) GetByUser() {
|
||||
// @Success 200 {group} string
|
||||
// @router / [get]
|
||||
func (o *GroupController) GetAll() {
|
||||
group, err := infrastructure.GetPermissionConnector().GetGroup("")
|
||||
clientID := ExtractClient(*o.Ctx.Request)
|
||||
group, err := infrastructure.GetPermissionConnector(clientID).GetGroup("")
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
@@ -92,7 +95,8 @@ func (o *GroupController) GetAll() {
|
||||
// @router /:id [get]
|
||||
func (o *GroupController) Get() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
group, err := infrastructure.GetPermissionConnector().GetGroup(id)
|
||||
clientID := ExtractClient(*o.Ctx.Request)
|
||||
group, err := infrastructure.GetPermissionConnector(clientID).GetGroup(id)
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
@@ -117,7 +121,8 @@ func (o *GroupController) Get() {
|
||||
// @router /:id [delete]
|
||||
func (o *GroupController) Delete() {
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
group, code, err := infrastructure.GetPermissionConnector().DeleteGroup(id)
|
||||
clientID := ExtractClient(*o.Ctx.Request)
|
||||
group, code, err := infrastructure.GetPermissionConnector(clientID).DeleteGroup(id)
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
@@ -140,7 +145,8 @@ func (o *GroupController) Delete() {
|
||||
// @Success 200 {string} delete success!
|
||||
// @router /clear [delete]
|
||||
func (o *GroupController) Clear() {
|
||||
group, code, err := infrastructure.GetPermissionConnector().DeleteGroup("")
|
||||
clientID := ExtractClient(*o.Ctx.Request)
|
||||
group, code, err := infrastructure.GetPermissionConnector(clientID).DeleteGroup("")
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
@@ -167,7 +173,8 @@ func (o *GroupController) Clear() {
|
||||
func (o *GroupController) Bind() {
|
||||
user_id := o.Ctx.Input.Param(":user_id")
|
||||
group_id := o.Ctx.Input.Param(":group_id")
|
||||
group, code, err := infrastructure.GetPermissionConnector().BindGroup(user_id, group_id)
|
||||
clientID := ExtractClient(*o.Ctx.Request)
|
||||
group, code, err := infrastructure.GetPermissionConnector(clientID).BindGroup(user_id, group_id)
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
@@ -187,14 +194,15 @@ func (o *GroupController) Bind() {
|
||||
|
||||
// @Title UnBind
|
||||
// @Description unbind the group to user
|
||||
// @Param group_id path string true "The group_id you want to unbind"
|
||||
// @Param user_id path string true "The group_id you want to unbind"
|
||||
// @Param group_id path string true "The user_id you want to unbind"
|
||||
// @Success 200 {string} bind success!
|
||||
// @router /:user_id/:group_id [delete]
|
||||
func (o *GroupController) UnBind() {
|
||||
user_id := o.Ctx.Input.Param(":user_id")
|
||||
group_id := o.Ctx.Input.Param(":group_id")
|
||||
group, code, err := infrastructure.GetPermissionConnector().UnBindGroup(user_id, group_id)
|
||||
clientID := ExtractClient(*o.Ctx.Request)
|
||||
group, code, err := infrastructure.GetPermissionConnector(clientID).UnBindGroup(user_id, group_id)
|
||||
if err != nil {
|
||||
o.Data["json"] = map[string]interface{}{
|
||||
"data": nil,
|
||||
|
||||
Reference in New Issue
Block a user