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 {
164
164
return false
165
165
}
166
166
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
+
167
187
func prepareSignInPageData (ctx * context.Context ) {
168
188
ctx .Data ["Title" ] = ctx .Tr ("sign_in" )
169
189
ctx .Data ["OAuth2Providers" ], _ = oauth2 .GetOAuth2Providers (ctx , optional .Some (true ))
@@ -185,6 +205,10 @@ func SignIn(ctx *context.Context) {
185
205
if CheckAutoLogin (ctx ) {
186
206
return
187
207
}
208
+ // BLENDER: Check if authentication is forced to OAuth
209
+ if checkForceOAuth (ctx ) {
210
+ return
211
+ }
188
212
if ctx .IsSigned {
189
213
RedirectAfterLogin (ctx )
190
214
return
You can’t perform that action at this time.
0 commit comments