Skip to content

Commit

Permalink
Make consoleperm work again and add a new group
Browse files Browse the repository at this point in the history
  • Loading branch information
Frizlab committed Sep 28, 2021
1 parent d1a05e3 commit 3886bcf
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ struct ConsolepermCommand : ParsableCommand {
abstract: "Set happn console permission for a user depending on a group."
)

@OptionGroup()
@OptionGroup
var globalOptions: OfficectlRootCommand.Options

@ArgumentParser.Argument()
@ArgumentParser.Argument
var usermail: String

@ArgumentParser.Argument()
@ArgumentParser.Argument
var group: String

func run() throws {
Expand Down Expand Up @@ -71,18 +71,17 @@ struct ConsolepermCommand : ParsableCommand {
return try nil2throw(user.id.value, "no userid… (should not happen!)")
}
.flatMap{ userId -> EventLoopFuture<String> in
return hConnector.connect(scope: Set(arrayLiteral: "acl_update", "acl_read"), eventLoop: eventLoop).map{ _ in userId }
return hConnector.connect(scope: Set(arrayLiteral: "acl_create", "acl_update", "acl_read"), eventLoop: eventLoop).map{ _ in userId }
}
.flatMap{ userId -> EventLoopFuture<(result: URLRequest, userInfo: Any?)> in
let url = hService.config.connectorSettings.baseURL.appendingPathComponent("api").appendingPathComponent("user-acls")
let url = hService.config.connectorSettings.baseURL.appendingPathComponent("api").appendingPathComponent("user-acls").appendingPathComponent(userId)

var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "POST"
urlRequest.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")

var urlComponents = URLComponents(string: "https://example.com")!
urlComponents.queryItems = [
URLQueryItem(name: "user_id", value: userId),
URLQueryItem(name: "permissions", value: permissions)
]
urlRequest.httpBody = Data(urlComponents.percentEncodedQuery!.utf8)
Expand Down

0 comments on commit 3886bcf

Please sign in to comment.