mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-16 05:18:38 +01:00
feature (oauth): redirection link for oauth
This commit is contained in:
parent
8d413214e2
commit
e13262dd36
2 changed files with 6 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
. "github.com/mickael-kerjean/filestash/server/common"
|
||||
"github.com/mickael-kerjean/filestash/server/model"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -142,5 +143,9 @@ func SessionOAuthBackend(ctx App, res http.ResponseWriter, req *http.Request) {
|
|||
SendErrorResult(res, ErrNotSupported)
|
||||
return
|
||||
}
|
||||
if strings.Contains(req.Header.Get("Accept"), "text/html") {
|
||||
http.Redirect(res, req, obj.OAuthURL(), http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
SendSuccessResult(res, obj.OAuthURL())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func Init(a *App) {
|
|||
session.HandleFunc("", NewMiddlewareChain(SessionAuthenticate, middlewares, *a)).Methods("POST")
|
||||
middlewares = []Middleware{ApiHeaders, SecureHeaders, SecureAjax, SessionTry}
|
||||
session.HandleFunc("", NewMiddlewareChain(SessionLogout, middlewares, *a)).Methods("DELETE")
|
||||
middlewares = []Middleware{ApiHeaders, SecureHeaders, SecureAjax}
|
||||
middlewares = []Middleware{ApiHeaders, SecureHeaders}
|
||||
session.HandleFunc("/auth/{service}", NewMiddlewareChain(SessionOAuthBackend, middlewares, *a)).Methods("GET")
|
||||
|
||||
// API for admin
|
||||
|
|
|
|||
Loading…
Reference in a new issue