mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vweb.csrf: add a README.md, correct doc comments for public functions (#15697)
This commit is contained in:
@ -6,7 +6,7 @@ const chars = 'QWERTZUIOPASDFGHJKLYXCVBNMqwertzuiopasdfghjklyxcvbnm1234567890_-'
|
||||
|
||||
const cookie_key = '__Host-Csrf-Token'
|
||||
|
||||
// set_csrf_cookie - generates a CSRF-Token and sets the CSRF-Cookie. It is possible to set the http-only-status of the cookie to false by adding an argument of the HttpOnly-struct like this:
|
||||
// set_csrf_cookie - generates a CSRF-Token and sets the CSRF-Cookie. It is possible to set the HttpOnly-status of the cookie to false by adding an argument of the HttpOnly-struct like this:
|
||||
// `app.set_csrf_cookie(csrf.HttpOnly{false})`
|
||||
// If no argument is set, http_only will be set to `true`by default.
|
||||
pub fn (mut app App) set_csrf_cookie(h ...HttpOnly) App {
|
||||
@ -44,7 +44,7 @@ fn create_cookie(h bool) CsrfCookie {
|
||||
}
|
||||
}
|
||||
|
||||
// get_csrf_token - returns the CSRF-Token that has been set. Make sure that you set one by using `set_csrf_cookie()`. If it's value is empty or no cookie has been generated, the function will thor an error.
|
||||
// get_csrf_token - returns the CSRF-Token that has been set. Make sure that you set one by using `set_csrf_cookie()`. If it's value is empty or no cookie has been generated, the function will throw an error.
|
||||
pub fn (mut app App) get_csrf_token() ?string {
|
||||
if app.csrf_cookie_value != '' {
|
||||
return app.csrf_cookie_value
|
||||
|
Reference in New Issue
Block a user