diff --git a/output/run.go b/output/run.go
index 65aeb6a..0cadce1 100644
--- a/output/run.go
+++ b/output/run.go
@@ -51,7 +51,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
var cmd *exec.Cmd
if conf.Docker {
fileName := filepath.Base(filePath)
- cmd = exec.Command("timeout", "5", "docker", "run", "--rm", "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName)
+ cmd = exec.Command("timeout", "5", "docker", "run", "--rm", "--cpus", "0.1", "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName)
} else {
cmd = exec.Command(filePath)
curDir := filepath.Dir(filePath)
diff --git a/playground/run.go b/playground/run.go
index 3d50de6..79387d6 100644
--- a/playground/run.go
+++ b/playground/run.go
@@ -52,7 +52,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
var cmd *exec.Cmd
if conf.Docker {
fileName := filepath.Base(filePath)
- cmd = exec.Command("timeout", "5", "docker", "run", "--rm", "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName)
+ cmd = exec.Command("timeout", "5", "docker", "run", "--rm", "--cpus", "0.1", "-v", filePath+":/"+fileName, conf.DockerImageGo, "/"+fileName)
} else {
cmd = exec.Command(filePath)
curDir := filepath.Dir(filePath)
diff --git a/session/oauthctl.go b/session/oauth.go
similarity index 96%
rename from session/oauthctl.go
rename to session/oauth.go
index 684c5b6..f83300c 100644
--- a/session/oauthctl.go
+++ b/session/oauth.go
@@ -16,7 +16,6 @@ package session
import (
"crypto/tls"
- "github.com/b3log/wide/i18n"
"html/template"
"math/rand"
"net/http"
@@ -27,6 +26,7 @@ import (
"time"
"github.com/b3log/wide/conf"
+ "github.com/b3log/wide/i18n"
"github.com/b3log/wide/util"
"github.com/parnurzeal/gorequest"
)
@@ -55,11 +55,9 @@ func RedirectGitHubHandler(w http.ResponseWriter, r *http.Request) {
clientId := data["clientId"].(string)
loginAuthURL := data["loginAuthURL"].(string)
- referer := r.URL.Query().Get("referer")
- if "" == referer || !strings.Contains(referer, "://") {
- referer = conf.Wide.Server + referer
- }
- state := util.Rand.String(16) + referer
+ state := r.URL.Query().Get("state")
+ referer := conf.Wide.Server + "__" + state
+ state = util.Rand.String(16) + referer
states[state] = state
path := loginAuthURL + "?client_id=" + clientId + "&state=" + state + "&scope=public_repo,read:user,user:follow"
http.Redirect(w, r, path, http.StatusSeeOther)
@@ -91,15 +89,14 @@ func GithubCallbackHandler(w http.ResponseWriter, r *http.Request) {
userName := githubUser["userName"].(string)
avatar := githubUser["userAvatarURL"].(string)
- result := util.NewResult()
- defer util.RetResult(w, r, result)
-
user := conf.GetUser(githubId)
if nil == user {
msg := addUser(githubId, userName, avatar)
if userCreated != msg {
+ result := util.NewResult()
result.Succ = false
result.Msg = msg
+ util.RetResult(w, r, result)
return
}
diff --git a/views/login.html b/views/login.html
index fc6b2af..9424d01 100644
--- a/views/login.html
+++ b/views/login.html
@@ -55,8 +55,7 @@