2

我正在处理 Auth0 Lock 集成,我收到错误Use of unresolved identifier 'connections'; 您的意思是“连接”吗?

.withConnections {_ in
  connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}

我将代码更改为

Connections.database(name: "Username-Password-Authentication", requiresUsername: true) 

现在我收到错误实例成员“数据库”不能用于类型“连接”

当我将代码更改为

Connections().database(name: "Username-Password-Authentication", requiresUsername: true)

无法构造错误“连接”,因为它没有可访问的初始化程序

我将代码更改为

$0.database(name: "Username-Password-Authentication", requiresUsername: true)

获取匿名闭包参数不能在具有显式参数的闭包内使用

https://github.com/auth0/Lock.swift

https://auth0.com/docs/libraries/lock-ios/v2#configuration-options

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    Lock
        .classic()
        // withConnections, withOptions, withStyle, and so on
        .withOptions {
            $0.oidcConformant = true
            $0.scope = "openid profile"
        }
        .onAuth { credentials in
            // Let's save our credentials.accessToken value
        }
        .withConnections {_ in
            connections.database(name: "Username-Password-Authentication", requiresUsername: true)
        }
        .withStyle {
            $0.title = "Company LLC"
            $0.logo = LazyImage(name: "123.png")
            $0.primaryColor = UIColor(red: 0.6784, green: 0.5412, blue: 0.7333, alpha: 1.0)
        }
        .present(from: self)
4

3 回答 3

2

似乎 Auth0 文档在这里是错误的。如果您查看Lock.swift 源文件,您会看到 aConnectionBuildable作为参数传递。您需要使用它来建立您的连接。

尝试这个:

.withConnections { connections in
    connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}

或使用匿名闭包参数同样的事情:

.withConnections {
    $0.database(name: "Username-Password-Authentication", requiresUsername: true)
}
于 2019-01-22T09:59:00.843 回答
2

错误出现在 .withConnections 的闭中您没有使用_命名参数

无参数

.withConnections { _ in }

带参数

.withConnections { connections in { connections.database(name: "Username-Password-Authentication", requiresUsername: true) }

于 2019-01-22T10:00:46.873 回答
1

你得到使用未解析的标识符“连接”;您指的是 'Connections' 吗?因为connections没有声明为闭包参数。

尝试:

.withConnections { connections in
  connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}

或者如果你想使用匿名参数,不要声明任何参数:

.withConnections { 
  $0.database(name: "Username-Password-Authentication", requiresUsername: true)
}
于 2019-01-22T10:05:07.533 回答