Skip to content

npp_usr_login

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

int npp_usr_login()

Description

Logs user in.

npp_usr_xxx functions directly read the query string / payload data.

Request must contain the following parameters:

If no USERSBY... compilation switch is present or NPP_USERS_BY_LOGIN is present:

  • login
  • passwd

If NPP_USERS_BY_EMAIL compilation switch is present:

  • email
  • passwd

and optionally:

  • keep

login parameter can contain either login or email. Database lookup is case-insensitive.

Returns

Returns OK or one of the error codes:

  • ERR_INVALID_REQUEST
  • ERR_INVALID_LOGIN
  • ERR_SERVER_TOOBUSY
  • ERR_INT_SERVER_ERROR

Example

void npp_app_main()
{
    // ...

    else if ( REQ("login") )
    {
        // show login form with action="do_login"
        render_login();
    }
    else if ( REQ("do_login") && REQ_POST )
    {
        ret = npp_usr_login();

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

Notes

Requires NPP_USERS compilation switch.

Clone this wiki locally