Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth): dependencies crash #663

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Sources/Auth/AuthAdmin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
//

import Foundation
import Helpers
import HTTPTypes
import Helpers

public struct AuthAdmin: Sendable {
let clientID: AuthClientID
let client: AuthClient

var configuration: AuthClient.Configuration { Dependencies[clientID].configuration }
var api: APIClient { Dependencies[clientID].api }
var encoder: JSONEncoder { Dependencies[clientID].encoder }
var configuration: AuthClient.Configuration { client.configuration }
var encoder: JSONEncoder { configuration.encoder }

/// Delete a user. Requires `service_role` key.
/// - Parameter id: The id of the user you want to delete.
Expand All @@ -24,7 +23,7 @@ public struct AuthAdmin: Sendable {
///
/// - Warning: Never expose your `service_role` key on the client.
public func deleteUser(id: String, shouldSoftDelete: Bool = false) async throws {
_ = try await api.execute(
_ = try await client.execute(
HTTPRequest(
url: configuration.url.appendingPathComponent("admin/users/\(id)"),
method: .delete,
Expand All @@ -46,7 +45,7 @@ public struct AuthAdmin: Sendable {
let aud: String
}

let httpResponse = try await api.execute(
let httpResponse = try await client.execute(
HTTPRequest(
url: configuration.url.appendingPathComponent("admin/users"),
method: .get,
Expand All @@ -69,7 +68,8 @@ public struct AuthAdmin: Sendable {
let links = httpResponse.headers[.link]?.components(separatedBy: ",") ?? []
if !links.isEmpty {
for link in links {
let page = link.components(separatedBy: ";")[0].components(separatedBy: "=")[1].prefix(while: \.isNumber)
let page = link.components(separatedBy: ";")[0].components(separatedBy: "=")[1].prefix(
while: \.isNumber)
let rel = link.components(separatedBy: ";")[1].components(separatedBy: "=")[1]

if rel == "\"last\"", let lastPage = Int(page) {
Expand Down
Loading
Loading