mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
ACL: authCommand() refactored into ACLAuthenticateUser().
This commit is contained in:
parent
87594a7470
commit
36d1588215
20
src/acl.c
20
src/acl.c
@ -888,6 +888,22 @@ int ACLCheckUserCredentials(robj *username, robj *password) {
|
||||
return C_ERR;
|
||||
}
|
||||
|
||||
/* This is like ACLCheckUserCredentials(), however if the user/pass
|
||||
* are correct, the connection is put in authenticated state and the
|
||||
* connection user reference is populated.
|
||||
*
|
||||
* The return value is C_OK or C_ERR with the same meaning as
|
||||
* ACLCheckUserCredentials(). */
|
||||
int ACLAuthenticateUser(client *c, robj *username, robj *password) {
|
||||
if (ACLCheckUserCredentials(username,password) == C_OK) {
|
||||
c->authenticated = 1;
|
||||
c->user = ACLGetUserByName(username->ptr,sdslen(username->ptr));
|
||||
return C_OK;
|
||||
} else {
|
||||
return C_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
/* For ACL purposes, every user has a bitmap with the commands that such
|
||||
* user is allowed to execute. In order to populate the bitmap, every command
|
||||
* should have an assigned ID (that is used to index the bitmap). This function
|
||||
@ -1605,9 +1621,7 @@ void authCommand(client *c) {
|
||||
password = c->argv[2];
|
||||
}
|
||||
|
||||
if (ACLCheckUserCredentials(username,password) == C_OK) {
|
||||
c->authenticated = 1;
|
||||
c->user = ACLGetUserByName(username->ptr,sdslen(username->ptr));
|
||||
if (ACLAuthenticateUser(c,username,password) == C_OK) {
|
||||
addReply(c,shared.ok);
|
||||
} else {
|
||||
addReplyError(c,"-WRONGPASS invalid username-password pair");
|
||||
|
Loading…
Reference in New Issue
Block a user