Skip to content

npp_usr_reset_password

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

int npp_usr_reset_password()

Description

Resets user password using emailed key.

npp_usr_xxx functions directly read the query string / payload data.

Request must contain the following parameters:

  • email (email)
  • k (key)
  • passwd (new password)
  • rpasswd (new password again)

Returns

Returns OK or one of the error codes:

  • ERR_INVALID_REQUEST
  • ERR_EMAIL_FORMAT
  • ERR_PASSWORD_TOO_SHORT
  • ERR_PASSWORD_DIFFERENT
  • ERR_LINK_EXPIRED
  • ERR_INT_SERVER_ERROR

Example

void npp_app_main()
{
    // ...

    else if ( REQ("preset") )
    {
        // show password reset form with action="do_preset"
        render_preset();
    }
    else if ( REQ("do_preset") && REQ_POST )
    {
        ret = npp_usr_reset_password();

        if ( ret == OK )
            RES_LOCATION("/login?msg=%d", MSG_PASSWORD_CHANGED);
        else
            RES_LOCATION("/preset?msg=%d", ret);
    }
}

Notes

Requires NPP_USERS compilation switch.

Clone this wiki locally