Skip to content

npp_usr_save_account

Jurek Muszyński edited this page Mar 28, 2024 · 4 revisions

int npp_usr_save_account()

Description

Saves or deletes user account. Existing password (opasswd) must be present to make any changes to the user account.

npp_usr_xxx functions directly read the query string / payload data.

Request must contain the following parameters:

  • email (email)
  • passwd (new password – if to be changed)
  • rpasswd (new password again)
  • opasswd (old password)

and optionally:

  • login (login)
  • name (name)
  • lang (language)
  • tz (time zone)
  • about (about)
  • phone (phone)
  • delete (if on and no delconf is present – WAR_BEFORE_DELETE will be returned)
  • delconf (if 1 – indicates that user confirmed their will to delete the account)

Returns

Returns OK or one of the error codes:

  • ERR_INVALID_REQUEST
  • ERR_EMAIL_EMPTY
  • ERR_EMAIL_FORMAT
  • ERR_EMAIL_FORMAT_OR_EMPTY
  • ERR_EMAIL_TAKEN
  • ERR_PASSWORD_TOO_SHORT
  • ERR_PASSWORD_DIFFERENT
  • ERR_OLD_PASSWORD
  • WAR_BEFORE_DELETE
  • MSG_ACCOUNT_DELETED
  • ERR_INT_SERVER_ERROR

Example

void npp_app_main()
{
    // ...

    else if ( REQ("myacc") )
    {
        // show my account form with action="save_myacc"
        render_myacc();
    }
    else if ( REQ("save_myacc") && REQ_POST )
    {
        ret = npp_usr_save_account();

        if ( ret == OK )
            RES_LOCATION("/myacc?msg=%d", MSG_CHANGES_SAVED);
        else
            RES_LOCATION("/myacc?msg=%d", ret);
    }
}

Notes

Requires NPP_USERS compilation switch.

Clone this wiki locally