-
Notifications
You must be signed in to change notification settings - Fork 4
npp_usr_add_user
int npp_usr_add_user(bool use_qs, const char *login, const char *email, const char *name, const char *passwd, const char *phone, const char *lang, const char *tz, const char *about, char group_id, char auth_level)
Creates user account without using current session, typically when system admin adds user account. This function has two modes, depending on use_qs argument: If use_qs is true, it uses query string (or payload if POST), much like npp_usr_create_account(). The rest of the arguments can be NULL. Otherwise it uses the arguments: login, email, name, passwd, phone, lang, tz, about. If passwd is NULL, then random, MIN_PASSWORD_LEN-long password will be generated.
auth_level is the authorization level for the new user. See Sessions in Node++ for authorization levels table.
npp_usr_xxx functions directly read the query string / payload data.
Request can contain the following parameters:
If no NPP_USERS_BY_xxx compilation switch is present or NPP_USERS_BY_LOGIN is present:
- login (mandatory)
- email (optionally)
If NPP_USERS_BY_EMAIL compilation switch is present:
- email (mandatory)
and also mandatory:
- passwd
- rpasswd
and optionally:
- name
- phone
- lang
- tz
- about
- message
Users created with npp_usr_add_user get status=USER_STATUS_PASSWORD_CHANGE, which will force password change upon their first login.
Unless NPP_DONT_NOTIFY_NEW_USER is defined, and if email is present, new user will be notified about their new account and password.
Returns OK or one of the error codes:
- ERR_INVALID_REQUEST
- ERR_WEBSITE_FIRST_LETTER
- ERR_USERNAME_TOO_SHORT
- ERR_USERNAME_CHARS
- ERR_USERNAME_TAKEN
- ERR_EMAIL_FORMAT_OR_EMPTY
- ERR_PASSWORD_TOO_SHORT
- ERR_PASSWORD_DIFFERENT
- ERR_ROBOT
- ERR_INT_SERVER_ERROR
Requires NPP_USERS compilation switch.