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

Added authorization to crud #74

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions Sources/Redis/CRUD.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import Async

extension RedisClient {
/// Authorizes the client
///
/// - returns: A future that will be completed (or failed) when the client is authorized
@discardableResult
public func authorize(with password: String) -> Future<RedisClient> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would returning Future<Void> make more sense here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it would make more sense. I forget the reason why I made it return a RedisClient.

return self.run(command: "AUTH", arguments: [RedisData(bulk: password)]).map(to: RedisClient.self) { result in
if case .error(let error) = result.storage {
throw error
} else {
return self
}
}
}

/// Stores the `value` at the key `key`
///
/// [Learn More →](https://docs.vapor.codes/3.0/redis/basics/#creating-a-record)
Expand Down