Merge pull request #28 from klondi/unrestricted_users
Allow unrestricted users on uhub
This commit is contained in:
@@ -19,11 +19,33 @@
|
||||
|
||||
#include "uhub.h"
|
||||
|
||||
/**
|
||||
* Returns 1 if a user is unrestricted.
|
||||
* Unrestricted users override the limits of flood and can send messages in
|
||||
* the name of other users.
|
||||
* This is useful for amongst other external chatrooms.
|
||||
*/
|
||||
int auth_cred_is_unrestricted(enum auth_credentials cred)
|
||||
{
|
||||
switch (cred)
|
||||
{
|
||||
case auth_cred_ubot:
|
||||
case auth_cred_opubot:
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int auth_cred_is_protected(enum auth_credentials cred)
|
||||
{
|
||||
switch (cred)
|
||||
{
|
||||
case auth_cred_bot:
|
||||
case auth_cred_ubot:
|
||||
case auth_cred_opbot:
|
||||
case auth_cred_opubot:
|
||||
case auth_cred_operator:
|
||||
case auth_cred_super:
|
||||
case auth_cred_admin:
|
||||
@@ -45,6 +67,9 @@ int auth_cred_is_registered(enum auth_credentials cred)
|
||||
switch (cred)
|
||||
{
|
||||
case auth_cred_bot:
|
||||
case auth_cred_ubot:
|
||||
case auth_cred_opbot:
|
||||
case auth_cred_opubot:
|
||||
case auth_cred_user:
|
||||
case auth_cred_operator:
|
||||
case auth_cred_super:
|
||||
@@ -64,6 +89,9 @@ const char* auth_cred_to_string(enum auth_credentials cred)
|
||||
{
|
||||
case auth_cred_none: return "none";
|
||||
case auth_cred_bot: return "bot";
|
||||
case auth_cred_ubot: return "ubot";
|
||||
case auth_cred_opbot: return "opbot";
|
||||
case auth_cred_opubot: return "opubot";
|
||||
case auth_cred_guest: return "guest";
|
||||
case auth_cred_user: return "user";
|
||||
case auth_cred_operator: return "operator";
|
||||
@@ -95,14 +123,20 @@ int auth_string_to_cred(const char* str, enum auth_credentials* out)
|
||||
if (!strcasecmp(str, "none")) { *out = auth_cred_none; return 1; }
|
||||
if (!strcasecmp(str, "user")) { *out = auth_cred_user; return 1; }
|
||||
if (!strcasecmp(str, "link")) { *out = auth_cred_link; return 1; }
|
||||
if (!strcasecmp(str, "ubot")) { *out = auth_cred_ubot; return 1; }
|
||||
return 0;
|
||||
|
||||
case 5:
|
||||
if (!strcasecmp(str, "admin")) { *out = auth_cred_admin; return 1; }
|
||||
if (!strcasecmp(str, "super")) { *out = auth_cred_super; return 1; }
|
||||
if (!strcasecmp(str, "opbot")) { *out = auth_cred_opbot; return 1; }
|
||||
if (!strcasecmp(str, "guest")) { *out = auth_cred_guest; return 1; }
|
||||
return 0;
|
||||
|
||||
case 6:
|
||||
if (!strcasecmp(str, "opubot")) { *out = auth_cred_opubot; return 1; }
|
||||
return 0;
|
||||
|
||||
case 8:
|
||||
if (!strcasecmp(str, "operator")) { *out = auth_cred_operator; return 1; }
|
||||
return 0;
|
||||
|
||||
@@ -23,15 +23,24 @@
|
||||
enum auth_credentials
|
||||
{
|
||||
auth_cred_none, /**<<< "User has no credentials (not yet logged in)" */
|
||||
auth_cred_bot, /**<<< "User is a robot" */
|
||||
auth_cred_guest, /**<<< "User is a guest (unregistered user)" */
|
||||
auth_cred_user, /**<<< "User is identified as a registered user" */
|
||||
auth_cred_bot, /**<<< "User is a robot" */
|
||||
auth_cred_ubot, /**<<< "User is an unrestricted robot" */
|
||||
auth_cred_operator, /**<<< "User is identified as a hub operator" */
|
||||
auth_cred_opbot, /**<<< "User is a operator robot" */
|
||||
auth_cred_opubot, /**<<< "User is an unrestricted operator robot" */
|
||||
auth_cred_super, /**<<< "User is a super user" (not used) */
|
||||
auth_cred_link, /**<<< "User is a link (not used currently)" */
|
||||
auth_cred_admin, /**<<< "User is identified as a hub administrator/owner" */
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns 1 if the credentials means that a user is unrestricted.
|
||||
* Returns 0 otherwise.
|
||||
*/
|
||||
int auth_cred_is_unrestricted(enum auth_credentials cred);
|
||||
|
||||
/**
|
||||
* Returns 1 if the credentials means that a user is protected.
|
||||
* Returns 0 otherwise.
|
||||
|
||||
Reference in New Issue
Block a user