Skip to content

Commit 7cae455

Browse files
brechtvlbartvdbraak
authored andcommitted
BLENDER: Always login with Blender ID, unless noredirect is specified
1 parent 31f9669 commit 7cae455

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

routers/web/auth/auth.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
167187
func 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

0 commit comments

Comments
 (0)