| 911 | : _rs(rs) {} |
| 912 | |
| 913 | brpc::RedisCommandHandlerResult Run(brpc::RedisConnContext* ctx, |
| 914 | const std::vector<butil::StringPiece>& args, |
| 915 | brpc::RedisReply* output, |
| 916 | bool flush_batched) { |
| 917 | if (args.size() < 1) { |
| 918 | output->SetError("ERR wrong number of arguments for 'AUTH' command"); |
| 919 | return brpc::REDIS_CMD_HANDLED; |
| 920 | } |
| 921 | const std::string password(args[1].data(), args[1].size()); |
| 922 | if (_rs->_password != password) { |
| 923 | output->SetError("ERR invalid username/password"); |
| 924 | return brpc::REDIS_CMD_HANDLED; |
| 925 | } |
| 926 | auto auth_session = new AuthSession(password); |
| 927 | ctx->reset_session(auth_session); |
| 928 | output->SetStatus("OK"); |
| 929 | return brpc::REDIS_CMD_HANDLED; |
| 930 | } |
| 931 | |
| 932 | private: |
| 933 | RedisServiceImpl* _rs; |
nothing calls this directly
no test coverage detected