-
Notifications
You must be signed in to change notification settings - Fork 2
CSRFT_OUT_INPUT
Jurek Muszyński edited this page Mar 28, 2024
·
5 revisions
Appends hidden input with user session's current CSRF token to a form.
None
/* --------------------------------------------------------------------------
Show My Account form
-------------------------------------------------------------------------- */
void myacc_form()
{
CSFRT_REFRESH;
// ...
OUT("<form action=\"save_myacc\" method=\"POST\">");
OUT_CSRFT;
OUT("<input name=\"name\">");
OUT("<input name=\"passwd\" type=\"password\">");
// ...
OUT("</form>");
// ...
}
/* --------------------------------------------------------------------------
APP main
-------------------------------------------------------------------------- */
void npp_app_main()
{
// ...
else if ( REQ("myacc") )
{
myacc_form();
}
else if ( REQ("save_myacc") )
{
if ( CSRFT_OK )
{
ret = npp_usr_save_account();
}
else
{
WAR("CSRFT validation failed");
ret = ERR_CSRFT;
}
if ( ret == OK )
RES_LOCATION("myacc?msg=%d", MSG_CHANGES_SAVED);
else if ( ret == MSG_ACCOUNT_DELETED )
RES_LOCATION("farewell");
else // error
RES_LOCATION("myacc?msg=%d", ret);
}
// ...
}