Skip to content
This repository has been archived by the owner on Oct 5, 2024. It is now read-only.

Commit

Permalink
adapt to new sweetygo api
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyangXYZ committed Mar 13, 2019
1 parent e231b0a commit 4fa3614
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
Binary file modified AssassinGo
Binary file not shown.
3 changes: 2 additions & 1 deletion web/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ func signin(ctx *sweetygo.Context) error {
claims["exp"] = time.Now().Add(time.Hour * 36).Unix()
t, _ := token.SignedString([]byte(config.SecretKey))
ctx.SetCookie("SG_Token", t)
ctx.JSON(200, 1, "success", map[string]string{"SG_Token": t})

a := assassin.New()
s := assassin.NewSiblings()
daddy.Son[username] = a
daddy.Sibling[username] = s
logger.Green.Println(username, "Has Signed In")

return ctx.JSON(200, 1, "success", map[string]string{"SG_Token": t})
return nil
}
return ctx.JSON(200, 0, "Username or Password Error.", nil)
}
Expand Down
2 changes: 1 addition & 1 deletion web/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func SetMiddlewares(app *sweetygo.SweetyGo) {
// cors
app.USE(func(ctx *sweetygo.Context) error {
ctx.Resp.Header().Set("Access-Control-Allow-Origin", "http://localhost:8080")
ctx.Resp.Header().Set("Access-Control-Allow-Origin", "http://localhost:8000")
ctx.Resp.Header().Set("Access-Control-Allow-Credentials", "true")
ctx.Next()
return nil
Expand Down
1 change: 1 addition & 0 deletions web/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func init() {
// Run Web GUI.
func Run() {
app := sweetygo.New()
app.SetTemplates("/web/templates", nil)
SetMiddlewares(app)
SetRouter(app)
app.Run(":8000")
Expand Down

0 comments on commit 4fa3614

Please sign in to comment.