diff options
author | skyblue <ssx205@gmail.com> | 2014-04-07 18:01:25 +0800 |
---|---|---|
committer | skyblue <ssx205@gmail.com> | 2014-04-07 18:01:25 +0800 |
commit | 05fb34eacdbec59fb8bcdf96c82c0855e6ec78d2 (patch) | |
tree | e12623184d69d5a674c77aa8a98aba4955301581 /web.go | |
parent | a92d67fa01983644ccdb3d7bc54993a60d185da5 (diff) |
first works oauth2(github). need to login with /user/login/github
Diffstat (limited to 'web.go')
-rw-r--r-- | web.go | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -20,13 +20,16 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" - "github.com/gogits/gogs/modules/oauth2" + //"github.com/gogits/gogs/modules/oauth2" "github.com/gogits/gogs/routers" "github.com/gogits/gogs/routers/admin" "github.com/gogits/gogs/routers/api/v1" "github.com/gogits/gogs/routers/dev" "github.com/gogits/gogs/routers/repo" "github.com/gogits/gogs/routers/user" + + "github.com/martini-contrib/oauth2" + "github.com/martini-contrib/sessions" ) var CmdWeb = cli.Command{ @@ -61,6 +64,7 @@ func runWeb(*cli.Context) { scope := "https://api.github.com/user" oauth2.PathCallback = "/oauth2callback" + m.Use(sessions.Sessions("my_session", sessions.NewCookieStore([]byte("secret123")))) m.Use(oauth2.Github(&oauth2.Options{ ClientId: "09383403ff2dc16daaa1", ClientSecret: "5f6e7101d30b77952aab22b75eadae17551ea6b5", @@ -88,7 +92,7 @@ func runWeb(*cli.Context) { m.Get("/avatar/:hash", avt.ServeHTTP) m.Group("/user", func(r martini.Router) { - r.Any("/login/github", user.SocialSignIn) + r.Any("/login/github", reqSignOut, oauth2.LoginRequired, user.SocialSignIn) r.Any("/login", binding.BindIgnErr(auth.LogInForm{}), user.SignIn) r.Any("/sign_up", binding.BindIgnErr(auth.RegisterForm{}), user.SignUp) r.Any("/forget_password", user.ForgotPasswd) |