Implement user setup for Google OAuth2 unregistered users

This commit is contained in:
2024-04-30 17:16:56 +07:00
parent da31733dcc
commit 65a6538b95
4 changed files with 269 additions and 11 deletions

View File

@ -3,6 +3,7 @@ package routes
import (
googleOauthHandler "github.com/fossyy/filekeeper/handler/auth/google"
googleOauthCallbackHandler "github.com/fossyy/filekeeper/handler/auth/google/callback"
googleOauthSetupHandler "github.com/fossyy/filekeeper/handler/auth/google/setup"
downloadHandler "github.com/fossyy/filekeeper/handler/download"
downloadFileHandler "github.com/fossyy/filekeeper/handler/download/file"
forgotPasswordHandler "github.com/fossyy/filekeeper/handler/forgotPassword"
@ -58,15 +59,16 @@ func SetupRoutes() *http.ServeMux {
}
})
//TODO make a setup route for unregistered google oauth user
//authRouter.HandleFunc("/google/setup", func(w http.ResponseWriter, r *http.Request) {
// switch r.Method {
// case http.MethodGet:
// middleware.Guest(googleOauthSetupHandler.GET, w, r)
// default:
// http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
// }
//})
authRouter.HandleFunc("/google/setup/{code}", func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
middleware.Guest(googleOauthSetupHandler.GET, w, r)
case http.MethodPost:
middleware.Guest(googleOauthSetupHandler.POST, w, r)
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}
})
handler.HandleFunc("/signin", func(w http.ResponseWriter, r *http.Request) {
switch r.Method {