Skip to content
Open
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
11 changes: 9 additions & 2 deletions Sources/SwiftRedis/Redis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ public class Redis {
/// Authenticate against the server
///
/// - Parameter pswd: String for the password.
/// - Parameter username: String for the username (optional).
/// - Parameter callback: callback function that is called after authenticating,
/// NSError will be nil if successful.
public func auth(_ pswd: String, callback: (NSError?) -> Void) {

public func auth(_ pswd: String, with username: String? = nil, callback: (NSError?) -> Void) {
if let username = username {
issueCommand("AUTH", username, pswd) {(response: RedisResponse) in
let (_, error) = self.redisOkResponseHandler(response, nilOk: false)
callback(error)
}
return
}
issueCommand("AUTH", pswd) {(response: RedisResponse) in
let (_, error) = self.redisOkResponseHandler(response, nilOk: false)
callback(error)
Expand Down