File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,18 @@ extension RedisClient {
71
71
. convertFromRESPValue ( to: String . self)
72
72
. map { return $0 == " OK " }
73
73
}
74
+
75
+ /// Requests the client to authenticate with Redis to allow other commands to be executed.
76
+ ///
77
+ /// [https://redis.io/commands/auth](https://redis.io/commands/auth)
78
+ /// - Parameter password: The password to authenticate with.
79
+ /// - Returns: A `NIO.EventLoopFuture` that resolves if the password was accepted, otherwise it fails.
80
+ @inlinable
81
+ public func authorize( with password: String ) -> EventLoopFuture < Void > {
82
+ let args = [ RESPValue ( bulk: password) ]
83
+ return send ( command: " AUTH " , with: args)
84
+ . map { _ in return ( ) }
85
+ }
74
86
75
87
/// Removes the specified keys. A key is ignored if it does not exist.
76
88
///
Original file line number Diff line number Diff line change @@ -71,10 +71,8 @@ extension RedisConnection {
71
71
guard let pw = password else {
72
72
return connection. eventLoop. makeSucceededFuture ( connection)
73
73
}
74
-
75
- let args = [ RESPValue ( bulk: pw) ]
76
- return connection. send ( command: " AUTH " , with: args)
77
- . map { _ in return connection }
74
+ return connection. authorize ( with: pw)
75
+ . map { return connection }
78
76
}
79
77
}
80
78
}
You can’t perform that action at this time.
0 commit comments