-
Notifications
You must be signed in to change notification settings - Fork 2
npp_usr_login
Jurek Muszyński edited this page Mar 28, 2024
·
4 revisions
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:
- passwd
and optionally:
- keep
login parameter can contain either login or email. Database lookup is case-insensitive.
Returns OK or one of the error codes:
- ERR_INVALID_REQUEST
- ERR_INVALID_LOGIN
- ERR_SERVER_TOOBUSY
- ERR_INT_SERVER_ERROR
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);
}
}
Requires NPP_USERS compilation switch.