rename handler functions

This commit is contained in:
Lakhan Samani
2021-07-23 14:25:32 +05:30
parent 8a4c3c3b74
commit af1121c07e
5 changed files with 8 additions and 10 deletions

View File

@@ -163,7 +163,7 @@ func processGithubUserInfo(state string, code string, c *gin.Context) error {
return nil
}
func HandleOAuthCallback(provider enum.OAuthProvider) gin.HandlerFunc {
func OAuthCallbackHandler(provider enum.OAuthProvider) gin.HandlerFunc {
return func(c *gin.Context) {
var err error
if provider == enum.GoogleProvider {

View File

@@ -10,7 +10,7 @@ import (
"github.com/yauthdev/yauth/server/session"
)
func HandleOAuthLogin(provider enum.OAuthProvider) gin.HandlerFunc {
func OAuthLoginHandler(provider enum.OAuthProvider) gin.HandlerFunc {
uuid := uuid.New()
oauthStateString := uuid.String()

View File

@@ -5,7 +5,6 @@ import (
"github.com/gin-gonic/gin"
)
// Defining the Playground handler
func PlaygroundHandler() gin.HandlerFunc {
h := playground.Handler("GraphQL", "/graphql")

View File

@@ -13,8 +13,7 @@ import (
"github.com/yauthdev/yauth/server/utils"
)
// Defining the Graphql handler
func VerifyEmail() gin.HandlerFunc {
func VerifyEmailHandler() gin.HandlerFunc {
return func(c *gin.Context) {
errorRes := gin.H{
"message": "invalid token",

View File

@@ -42,14 +42,14 @@ func main() {
r.Use(CORSMiddleware())
r.GET("/", handlers.PlaygroundHandler())
r.POST("/graphql", handlers.GraphqlHandler())
r.GET("/verify_email", handlers.VerifyEmail())
r.GET("/verify_email", handlers.VerifyEmailHandler())
if oauth.OAuthProvider.GoogleConfig != nil {
r.GET("/login/google", handlers.HandleOAuthLogin(enum.GoogleProvider))
r.GET("/callback/google", handlers.HandleOAuthCallback(enum.GoogleProvider))
r.GET("/login/google", handlers.OAuthLoginHandler(enum.GoogleProvider))
r.GET("/callback/google", handlers.OAuthCallbackHandler(enum.GoogleProvider))
}
if oauth.OAuthProvider.GithubConfig != nil {
r.GET("/login/github", handlers.HandleOAuthLogin(enum.GithubProvider))
r.GET("/callback/github", handlers.HandleOAuthCallback(enum.GithubProvider))
r.GET("/login/github", handlers.OAuthLoginHandler(enum.GithubProvider))
r.GET("/callback/github", handlers.OAuthCallbackHandler(enum.GithubProvider))
}
r.Run()
}