-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change oauth package to improve readability and ensure individual res…
…ponsibility
- Loading branch information
1 parent
f60736d
commit edf0075
Showing
17 changed files
with
496 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package oauth | ||
|
||
import "go.uber.org/fx" | ||
|
||
func Module() fx.Option { | ||
return fx.Module("oauth", | ||
fx.Provide(NewOAuthService), | ||
fx.Provide(NewOAuthHandler), | ||
fx.Invoke(SetOAuthAPIRoutes), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package oauth | ||
|
||
import ( | ||
"gorm.io/gorm" | ||
) | ||
|
||
//go:generate go-enum --marshal --sql -f oauth.go | ||
|
||
type OAuth struct { | ||
gorm.Model | ||
UserID uint | ||
Provider Provider | ||
Identifier string | ||
} | ||
|
||
func (OAuth) TableName() string { return "oauths" } | ||
|
||
// ENUM(github) | ||
type Provider int |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package user | ||
package oauth | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package oauth | ||
|
||
import "github.com/labstack/echo/v4" | ||
|
||
func SetOAuthAPIRoutes(server *echo.Echo, handler *OAuthHandler) { | ||
registerProviders() | ||
server.Use(AuthMiddleware(handler.service)) | ||
auth := server.Group("/auth") | ||
|
||
auth.GET("", handler.AuthLogin) | ||
auth.GET("/logout", handler.AuthLogout) | ||
auth.GET("/callback", handler.AuthCallback) | ||
} |
Oops, something went wrong.