|
@@ -20,16 +20,13 @@ import (
|
|
"github.com/gogits/gogs/modules/base"
|
|
"github.com/gogits/gogs/modules/base"
|
|
"github.com/gogits/gogs/modules/log"
|
|
"github.com/gogits/gogs/modules/log"
|
|
"github.com/gogits/gogs/modules/middleware"
|
|
"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"
|
|
"github.com/gogits/gogs/routers/admin"
|
|
"github.com/gogits/gogs/routers/admin"
|
|
"github.com/gogits/gogs/routers/api/v1"
|
|
"github.com/gogits/gogs/routers/api/v1"
|
|
"github.com/gogits/gogs/routers/dev"
|
|
"github.com/gogits/gogs/routers/dev"
|
|
"github.com/gogits/gogs/routers/repo"
|
|
"github.com/gogits/gogs/routers/repo"
|
|
"github.com/gogits/gogs/routers/user"
|
|
"github.com/gogits/gogs/routers/user"
|
|
-
|
|
|
|
- "github.com/martini-contrib/oauth2"
|
|
|
|
- "github.com/martini-contrib/sessions"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
var CmdWeb = cli.Command{
|
|
var CmdWeb = cli.Command{
|
|
@@ -63,12 +60,17 @@ func runWeb(*cli.Context) {
|
|
m.Use(middleware.InitContext())
|
|
m.Use(middleware.InitContext())
|
|
|
|
|
|
scope := "https://api.github.com/user"
|
|
scope := "https://api.github.com/user"
|
|
- oauth2.PathCallback = "/oauth2callback"
|
|
|
|
- m.Use(sessions.Sessions("my_session", sessions.NewCookieStore([]byte("secret123"))))
|
|
|
|
|
|
+ // m.Use(sessions.Sessions("my_session", sessions.NewCookieStore([]byte("secret123"))))
|
|
|
|
+ // m.Use(oauth2.Github(&oauth2.Options{
|
|
|
|
+ // ClientId: "09383403ff2dc16daaa1",
|
|
|
|
+ // ClientSecret: "5f6e7101d30b77952aab22b75eadae17551ea6b5",
|
|
|
|
+ // RedirectURL: base.AppUrl + oauth2.PathCallback,
|
|
|
|
+ // Scopes: []string{scope},
|
|
|
|
+ // }))
|
|
m.Use(oauth2.Github(&oauth2.Options{
|
|
m.Use(oauth2.Github(&oauth2.Options{
|
|
- ClientId: "09383403ff2dc16daaa1",
|
|
|
|
- ClientSecret: "5f6e7101d30b77952aab22b75eadae17551ea6b5",
|
|
|
|
- RedirectURL: base.AppUrl + oauth2.PathCallback,
|
|
|
|
|
|
+ ClientId: "ba323b44192e65c7c320",
|
|
|
|
+ ClientSecret: "6818ffed53bea5815bf1a6412d1933f25fa10619",
|
|
|
|
+ RedirectURL: base.AppUrl + oauth2.PathCallback[1:],
|
|
Scopes: []string{scope},
|
|
Scopes: []string{scope},
|
|
}))
|
|
}))
|
|
|
|
|
|
@@ -92,8 +94,8 @@ func runWeb(*cli.Context) {
|
|
m.Get("/avatar/:hash", avt.ServeHTTP)
|
|
m.Get("/avatar/:hash", avt.ServeHTTP)
|
|
|
|
|
|
m.Group("/user", func(r martini.Router) {
|
|
m.Group("/user", func(r martini.Router) {
|
|
- r.Any("/login/github", reqSignOut, oauth2.LoginRequired, user.SocialSignIn)
|
|
|
|
r.Any("/login", binding.BindIgnErr(auth.LogInForm{}), user.SignIn)
|
|
r.Any("/login", binding.BindIgnErr(auth.LogInForm{}), user.SignIn)
|
|
|
|
+ r.Any("/login/github", oauth2.LoginRequired, user.SocialSignIn)
|
|
r.Any("/sign_up", binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
|
r.Any("/sign_up", binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
|
r.Any("/forget_password", user.ForgotPasswd)
|
|
r.Any("/forget_password", user.ForgotPasswd)
|
|
r.Any("/reset_password", user.ResetPasswd)
|
|
r.Any("/reset_password", user.ResetPasswd)
|