Authenticate the client associated with the context with * the provided user. Returns REDISMODULE_OK on success and * REDISMODULE_ERR on error. * * This authentication can be tracked with the optional callback and private * data fields. The callback will be called whenever the user of the client * changes. This callback should be used to cleanup any state that is being * kept in the modul
| 6732 | * client and do the authentication in the background and then attach the user |
| 6733 | * to the client in a threadsafe context. */ |
| 6734 | static int authenticateClientWithUser(RedisModuleCtx *ctx, user *user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { |
| 6735 | if (user->flags & USER_FLAG_DISABLED) { |
| 6736 | return REDISMODULE_ERR; |
| 6737 | } |
| 6738 | |
| 6739 | /* Avoid settings which are meaningless and will be lost */ |
| 6740 | if (!ctx->client || (ctx->client->flags & CLIENT_MODULE)) { |
| 6741 | return REDISMODULE_ERR; |
| 6742 | } |
| 6743 | |
| 6744 | moduleNotifyUserChanged(ctx->client); |
| 6745 | |
| 6746 | ctx->client->user = user; |
| 6747 | ctx->client->authenticated = 1; |
| 6748 | |
| 6749 | if (callback) { |
| 6750 | ctx->client->auth_callback = callback; |
| 6751 | ctx->client->auth_callback_privdata = privdata; |
| 6752 | ctx->client->auth_module = ctx->module; |
| 6753 | } |
| 6754 | |
| 6755 | if (client_id) { |
| 6756 | *client_id = ctx->client->id; |
| 6757 | } |
| 6758 | |
| 6759 | return REDISMODULE_OK; |
| 6760 | } |
| 6761 | |
| 6762 | |
| 6763 | /* Authenticate the current context's user with the provided redis acl user. |
no test coverage detected