Skip to content

Commit b065c71

Browse files
committed
Add possibility to enter password in PostgreSQLDatabaseConfig
1 parent b919eff commit b065c71

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Sources/PostgreSQL/Database/PostgreSQLDatabase.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class PostgreSQLDatabase: Database {
1818
do {
1919
let client = try PostgreSQLConnection.connect(hostname: config.hostname, port: config.port, on: worker)
2020
client.logger = logger
21-
return client.authenticate(username: config.username).transform(to: client)
21+
return client.authenticate(username: config.username, password: config.password).transform(to: client)
2222
} catch {
2323
return Future(error: error)
2424
}

Sources/PostgreSQL/Database/PostgreSQLDatabaseConfig.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ public struct PostgreSQLDatabaseConfig {
1313

1414
/// Username to authenticate.
1515
public let username: String
16-
16+
public let password: String?
17+
1718
/// Creates a new `PostgreSQLDatabaseConfig`.
18-
public init(hostname: String, port: UInt16, username: String) {
19+
public init(hostname: String, port: UInt16, username: String, password: String? = nil) {
1920
self.hostname = hostname
2021
self.port = port
2122
self.username = username
23+
self.password = password
2224
}
2325
}

0 commit comments

Comments
 (0)