HandleUserAuth handles the user oauth authorize process.
(c *gin.Context, provider string, clientID string, clientSecret string, callback string)
| 57 | |
| 58 | // HandleUserAuth handles the user oauth authorize process. |
| 59 | func HandleUserAuth(c *gin.Context, provider string, clientID string, clientSecret string, callback string) { |
| 60 | switch provider { |
| 61 | case "google": |
| 62 | google.StateHandler( |
| 63 | gologin.DebugOnlyCookieConfig, |
| 64 | google.LoginHandler( |
| 65 | getGoogleConfig( |
| 66 | clientID, |
| 67 | clientSecret, |
| 68 | callback, |
| 69 | ), nil), |
| 70 | ).ServeHTTP(c.Writer, c.Request) |
| 71 | case "facebook": |
| 72 | facebook.StateHandler( |
| 73 | gologin.DebugOnlyCookieConfig, |
| 74 | facebook.LoginHandler( |
| 75 | getFacebookConfig( |
| 76 | clientID, |
| 77 | clientSecret, |
| 78 | callback, |
| 79 | ), nil), |
| 80 | ).ServeHTTP(c.Writer, c.Request) |
| 81 | case "twitter": |
| 82 | twitter.LoginHandler(getTwitterConfig( |
| 83 | clientID, |
| 84 | clientSecret, |
| 85 | callback, |
| 86 | ), nil).ServeHTTP(c.Writer, c.Request) |
| 87 | case "github": |
| 88 | github.StateHandler( |
| 89 | gologin.DebugOnlyCookieConfig, |
| 90 | github.LoginHandler( |
| 91 | getGithubConfig( |
| 92 | clientID, |
| 93 | clientSecret, |
| 94 | callback, |
| 95 | ), nil), |
| 96 | ).ServeHTTP(c.Writer, c.Request) |
| 97 | case "weibo": |
| 98 | oauth2Login.StateHandler( |
| 99 | gologin.DebugOnlyCookieConfig, |
| 100 | oauth2Login.LoginHandler( |
| 101 | getSinaWeiboConfig( |
| 102 | clientID, |
| 103 | clientSecret, |
| 104 | callback, |
| 105 | ), nil), |
| 106 | ).ServeHTTP(c.Writer, c.Request) |
| 107 | default: |
| 108 | _ = c.AbortWithError(http.StatusBadRequest, ErrUnsupportedUserAuthProvider) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | // HandleUserCallback handles the user oauth callback process. |
| 113 | func HandleUserCallback(c *gin.Context, provider string, clientID string, clientSecret string, |
no test coverage detected