This commit is contained in:
Liang Ding 2014-08-31 17:39:39 +08:00
parent 355e64e680
commit d0d454aa03
7 changed files with 19 additions and 19 deletions

View File

@ -3,7 +3,7 @@ package editor
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"github.com/b3log/wide/session" "github.com/b3log/wide/user"
"github.com/b3log/wide/util" "github.com/b3log/wide/util"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
@ -16,7 +16,7 @@ import (
var editorWS = map[string]*websocket.Conn{} var editorWS = map[string]*websocket.Conn{}
func WSHandler(w http.ResponseWriter, r *http.Request) { func WSHandler(w http.ResponseWriter, r *http.Request) {
session, _ := session.Store.Get(r, "wide-session") session, _ := user.Session.Get(r, "wide-session")
sid := session.Values["id"].(string) sid := session.Values["id"].(string)
editorWS[sid], _ = websocket.Upgrade(w, r, nil, 1024, 1024) editorWS[sid], _ = websocket.Upgrade(w, r, nil, 1024, 1024)

View File

@ -3,7 +3,7 @@ package file
import ( import (
"encoding/json" "encoding/json"
"github.com/b3log/wide/conf" "github.com/b3log/wide/conf"
"github.com/b3log/wide/session" "github.com/b3log/wide/user"
"github.com/golang/glog" "github.com/golang/glog"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -14,7 +14,7 @@ import (
) )
func GetFiles(w http.ResponseWriter, r *http.Request) { func GetFiles(w http.ResponseWriter, r *http.Request) {
session, _ := session.Store.Get(r, "wide-session") session, _ := user.Session.Get(r, "wide-session")
username := session.Values["name"].(string) username := session.Values["name"].(string)

View File

@ -6,8 +6,8 @@ import (
"github.com/b3log/wide/file" "github.com/b3log/wide/file"
"github.com/b3log/wide/i18n" "github.com/b3log/wide/i18n"
"github.com/b3log/wide/output" "github.com/b3log/wide/output"
"github.com/b3log/wide/session"
"github.com/b3log/wide/shell" "github.com/b3log/wide/shell"
"github.com/b3log/wide/user"
"github.com/golang/glog" "github.com/golang/glog"
"html/template" "html/template"
"math/rand" "math/rand"
@ -18,7 +18,7 @@ import (
func indexHandler(w http.ResponseWriter, r *http.Request) { func indexHandler(w http.ResponseWriter, r *http.Request) {
model := map[string]interface{}{"Wide": conf.Wide, "i18n": i18n.GetLangs(r)} model := map[string]interface{}{"Wide": conf.Wide, "i18n": i18n.GetLangs(r)}
session, _ := session.Store.Get(r, "wide-session") session, _ := user.Session.Get(r, "wide-session")
if session.IsNew { if session.IsNew {
// TODO: 以 daniel 作为用户登录 // TODO: 以 daniel 作为用户登录

View File

@ -3,7 +3,7 @@ package output
import ( import (
"encoding/json" "encoding/json"
"github.com/b3log/wide/conf" "github.com/b3log/wide/conf"
"github.com/b3log/wide/session" "github.com/b3log/wide/user"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"io" "io"
@ -18,7 +18,7 @@ import (
var outputWS = map[string]*websocket.Conn{} var outputWS = map[string]*websocket.Conn{}
func WSHandler(w http.ResponseWriter, r *http.Request) { func WSHandler(w http.ResponseWriter, r *http.Request) {
session, _ := session.Store.Get(r, "wide-session") session, _ := user.Session.Get(r, "wide-session")
sid := session.Values["id"].(string) sid := session.Values["id"].(string)
outputWS[sid], _ = websocket.Upgrade(w, r, nil, 1024, 1024) outputWS[sid], _ = websocket.Upgrade(w, r, nil, 1024, 1024)
@ -30,7 +30,7 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
} }
func RunHandler(w http.ResponseWriter, r *http.Request) { func RunHandler(w http.ResponseWriter, r *http.Request) {
session, _ := session.Store.Get(r, "wide-session") session, _ := user.Session.Get(r, "wide-session")
sid := session.Values["id"].(string) sid := session.Values["id"].(string)
decoder := json.NewDecoder(r.Body) decoder := json.NewDecoder(r.Body)
@ -105,7 +105,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
} }
func BuildHandler(w http.ResponseWriter, r *http.Request) { func BuildHandler(w http.ResponseWriter, r *http.Request) {
session, _ := session.Store.Get(r, "wide-session") session, _ := user.Session.Get(r, "wide-session")
sid := session.Values["id"].(string) sid := session.Values["id"].(string)
decoder := json.NewDecoder(r.Body) decoder := json.NewDecoder(r.Body)

View File

@ -1,7 +0,0 @@
package session
import (
"github.com/gorilla/sessions"
)
var Store = sessions.NewCookieStore([]byte("BEYOND"))

View File

@ -2,7 +2,7 @@ package shell
import ( import (
"github.com/b3log/wide/conf" "github.com/b3log/wide/conf"
"github.com/b3log/wide/session" "github.com/b3log/wide/user"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"net/http" "net/http"
@ -14,7 +14,7 @@ import (
var shellWS = map[string]*websocket.Conn{} var shellWS = map[string]*websocket.Conn{}
func WSHandler(w http.ResponseWriter, r *http.Request) { func WSHandler(w http.ResponseWriter, r *http.Request) {
session, _ := session.Store.Get(r, "wide-session") session, _ := user.Session.Get(r, "wide-session")
sid := session.Values["id"].(string) sid := session.Values["id"].(string)
shellWS[sid], _ = websocket.Upgrade(w, r, nil, 1024, 1024) shellWS[sid], _ = websocket.Upgrade(w, r, nil, 1024, 1024)

7
user/sessions.go Normal file
View File

@ -0,0 +1,7 @@
package user
import (
"github.com/gorilla/sessions"
)
var Session = sessions.NewCookieStore([]byte("BEYOND"))