File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,26 @@ func CheckAutoLogin(ctx *context.Context) bool {
164164 return false
165165}
166166
167+ // BLENDER: always use OAuth unless ?noredirect=true is set
168+ func checkForceOAuth (ctx * context.Context ) bool {
169+ // Check if authentication is forced to OAuth
170+ if ctx .FormBool ("noredirect" ) {
171+ return false
172+ }
173+
174+ oauth2Providers , err := oauth2 .GetOAuth2Providers (ctx , optional .Some (true ))
175+ if err != nil {
176+ return false
177+ }
178+
179+ for _ , provider := range oauth2Providers {
180+ ctx .Redirect (setting .AppSubURL + "/user/oauth2/" + provider .Name ())
181+ return true
182+ }
183+
184+ return false
185+ }
186+
167187func prepareSignInPageData (ctx * context.Context ) {
168188 ctx .Data ["Title" ] = ctx .Tr ("sign_in" )
169189 ctx .Data ["OAuth2Providers" ], _ = oauth2 .GetOAuth2Providers (ctx , optional .Some (true ))
@@ -185,6 +205,10 @@ func SignIn(ctx *context.Context) {
185205 if CheckAutoLogin (ctx ) {
186206 return
187207 }
208+ // BLENDER: Check if authentication is forced to OAuth
209+ if checkForceOAuth (ctx ) {
210+ return
211+ }
188212 if ctx .IsSigned {
189213 RedirectAfterLogin (ctx )
190214 return
You can’t perform that action at this time.
0 commit comments