Commit 05292e34 authored by Madelyn Olson's avatar Madelyn Olson
Browse files

Improved some error handling in examples

parent 75d97714
......@@ -5216,7 +5216,7 @@ RedisModuleUser *RM_CreateModuleUser(const char *name) {
RedisModuleUser *new_user = zmalloc(sizeof(RedisModuleUser));
new_user->user = ACLCreateUnlinkedUser();
/* Free the previous temporarily assigned name to assign the new one */
/* Free the temporarily assigned name to assign the new one */
sdsfree(new_user->user->name);
new_user->user->name = sdsnew(name);
return new_user;
......@@ -5262,6 +5262,8 @@ RedisModuleAuthCtx *RM_CreateAuthCtx(RedisModuleUserChangedFunc callback, void *
RedisModuleAuthCtx *auth_ctx = zmalloc(sizeof(RedisModuleAuthCtx));
auth_ctx->callback = callback;
auth_ctx->privdata = privdata;
auth_ctx->module = NULL;
auth_ctx->authenticated_client = NULL;
return auth_ctx;
}
......
......@@ -92,7 +92,11 @@ int AuthGlobalCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv
}
RedisModuleAuthCtx *auth_ctx = RedisModule_CreateAuthCtx(HelloACL_UserChanged, NULL);
RedisModule_AuthClientWithUser(ctx, global, auth_ctx);
if (RedisModule_AuthClientWithUser(ctx, global, auth_ctx) ==
REDISMODULE_ERR) {
return RedisModule_ReplyWithError(ctx, "Couldn't authenticate client");
}
global_auth_ctx = auth_ctx;
return RedisModule_ReplyWithSimpleString(ctx, "OK");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment