Browse Source

pass valid context to Exchange code

Morgan Bazalgette 10 months ago
parent
commit
91d8c6234c
Signed by: Morgan Bazalgette <the@howl.moe> GPG Key ID: 40D328300D245DA5
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      helpers.go

+ 4
- 1
helpers.go View File

@@ -1,6 +1,7 @@
1 1
 package main
2 2
 
3 3
 import (
4
+	gocontext "context"
4 5
 	"crypto/md5"
5 6
 	"encoding/json"
6 7
 	"fmt"
@@ -8,6 +9,7 @@ import (
8 9
 	"net/http"
9 10
 	"net/url"
10 11
 	"strings"
12
+	"time"
11 13
 
12 14
 	"bytes"
13 15
 
@@ -98,7 +100,8 @@ func discordFinish(c *gin.Context) {
98 100
 		return
99 101
 	}
100 102
 
101
-	tok, err := getDiscord().Exchange(nil, c.Query("code"))
103
+	reqCtx, _ := gocontext.WithTimeout(gocontext.Background(), time.Second*20)
104
+	tok, err := getDiscord().Exchange(reqCtx, c.Query("code"))
102 105
 	if err != nil {
103 106
 		c.Error(err)
104 107
 		addMessage(c, errorMessage{T(c, "An error occurred.")})

Loading…
Cancel
Save