Remove unneeded comments
This commit is contained in:
parent
3336bd0b3f
commit
5ae84c1995
@ -21,7 +21,6 @@ func GenerateCsrfToken(w http.ResponseWriter, _ *http.Request) (string, error) {
|
|||||||
str := hex.EncodeToString(buff)
|
str := hex.EncodeToString(buff)
|
||||||
token := str[:64]
|
token := str[:64]
|
||||||
|
|
||||||
// Create session cookie, containing token
|
|
||||||
cookie := &http.Cookie{
|
cookie := &http.Cookie{
|
||||||
Name: "csrf_token",
|
Name: "csrf_token",
|
||||||
Value: token,
|
Value: token,
|
||||||
@ -38,7 +37,6 @@ func GenerateCsrfToken(w http.ResponseWriter, _ *http.Request) (string, error) {
|
|||||||
|
|
||||||
// VerifyCsrfToken verifies the csrf token
|
// VerifyCsrfToken verifies the csrf token
|
||||||
func VerifyCsrfToken(r *http.Request) (bool, error) {
|
func VerifyCsrfToken(r *http.Request) (bool, error) {
|
||||||
// Get csrf cookie
|
|
||||||
cookie, err := r.Cookie("csrf_token")
|
cookie, err := r.Cookie("csrf_token")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error getting csrf_token cookie")
|
log.Println("Error getting csrf_token cookie")
|
||||||
@ -46,10 +44,8 @@ func VerifyCsrfToken(r *http.Request) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get csrf token from form
|
|
||||||
token := r.FormValue("csrf_token")
|
token := r.FormValue("csrf_token")
|
||||||
|
|
||||||
// Compare csrf cookie and csrf token
|
|
||||||
if cookie.Value == token {
|
if cookie.Value == token {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user