Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a236fc195c
|
@ -51,7 +51,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if conf.Docker {
|
if conf.Docker {
|
||||||
fileName := filepath.Base(filePath)
|
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 {
|
} else {
|
||||||
cmd = exec.Command(filePath)
|
cmd = exec.Command(filePath)
|
||||||
curDir := filepath.Dir(filePath)
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
|
@ -52,7 +52,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
if conf.Docker {
|
if conf.Docker {
|
||||||
fileName := filepath.Base(filePath)
|
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 {
|
} else {
|
||||||
cmd = exec.Command(filePath)
|
cmd = exec.Command(filePath)
|
||||||
curDir := filepath.Dir(filePath)
|
curDir := filepath.Dir(filePath)
|
||||||
|
|
|
@ -16,7 +16,6 @@ package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"github.com/b3log/wide/i18n"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -27,6 +26,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/b3log/wide/conf"
|
"github.com/b3log/wide/conf"
|
||||||
|
"github.com/b3log/wide/i18n"
|
||||||
"github.com/b3log/wide/util"
|
"github.com/b3log/wide/util"
|
||||||
"github.com/parnurzeal/gorequest"
|
"github.com/parnurzeal/gorequest"
|
||||||
)
|
)
|
||||||
|
@ -55,11 +55,9 @@ func RedirectGitHubHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
clientId := data["clientId"].(string)
|
clientId := data["clientId"].(string)
|
||||||
loginAuthURL := data["loginAuthURL"].(string)
|
loginAuthURL := data["loginAuthURL"].(string)
|
||||||
|
|
||||||
referer := r.URL.Query().Get("referer")
|
state := r.URL.Query().Get("state")
|
||||||
if "" == referer || !strings.Contains(referer, "://") {
|
referer := conf.Wide.Server + "__" + state
|
||||||
referer = conf.Wide.Server + referer
|
state = util.Rand.String(16) + referer
|
||||||
}
|
|
||||||
state := util.Rand.String(16) + referer
|
|
||||||
states[state] = state
|
states[state] = state
|
||||||
path := loginAuthURL + "?client_id=" + clientId + "&state=" + state + "&scope=public_repo,read:user,user:follow"
|
path := loginAuthURL + "?client_id=" + clientId + "&state=" + state + "&scope=public_repo,read:user,user:follow"
|
||||||
http.Redirect(w, r, path, http.StatusSeeOther)
|
http.Redirect(w, r, path, http.StatusSeeOther)
|
||||||
|
@ -91,15 +89,14 @@ func GithubCallbackHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
userName := githubUser["userName"].(string)
|
userName := githubUser["userName"].(string)
|
||||||
avatar := githubUser["userAvatarURL"].(string)
|
avatar := githubUser["userAvatarURL"].(string)
|
||||||
|
|
||||||
result := util.NewResult()
|
|
||||||
defer util.RetResult(w, r, result)
|
|
||||||
|
|
||||||
user := conf.GetUser(githubId)
|
user := conf.GetUser(githubId)
|
||||||
if nil == user {
|
if nil == user {
|
||||||
msg := addUser(githubId, userName, avatar)
|
msg := addUser(githubId, userName, avatar)
|
||||||
if userCreated != msg {
|
if userCreated != msg {
|
||||||
|
result := util.NewResult()
|
||||||
result.Succ = false
|
result.Succ = false
|
||||||
result.Msg = msg
|
result.Msg = msg
|
||||||
|
util.RetResult(w, r, result)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
|
@ -55,8 +55,7 @@
|
||||||
<script type="text/javascript" src="/static/js/lib/jquery-2.1.1.min.js"></script>
|
<script type="text/javascript" src="/static/js/lib/jquery-2.1.1.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$('.oauth').click(function () {
|
$('.oauth').click(function () {
|
||||||
window.location.href = '/oauth/github/redirect?referer=' + document.referrer + '__' +
|
window.location.href = '/oauth/github/redirect?state=' + ($('input').prop('checked') ? '0' : '1')
|
||||||
($('input').prop('checked') ? '0' : '1')
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue