Skip to content

Commit d6fd250

Browse files
committed
OpenID respect setting too
1 parent 7fbe606 commit d6fd250

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

routers/user/auth_openid.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func signInOpenIDVerify(ctx *context.Context) {
249249
log.Error("signInOpenIDVerify: Unable to save changes to the session: %v", err)
250250
}
251251

252-
if u != nil || !setting.Service.EnableOpenIDSignUp {
252+
if u != nil || !setting.Service.EnableOpenIDSignUp || setting.Service.AllowOnlyInternalRegistration {
253253
ctx.Redirect(setting.AppSubURL + "/user/openid/connect")
254254
} else {
255255
ctx.Redirect(setting.AppSubURL + "/user/openid/register")
@@ -267,6 +267,7 @@ func ConnectOpenID(ctx *context.Context) {
267267
ctx.Data["PageIsSignIn"] = true
268268
ctx.Data["PageIsOpenIDConnect"] = true
269269
ctx.Data["EnableOpenIDSignUp"] = setting.Service.EnableOpenIDSignUp
270+
ctx.Data["AllowOnlyInternalRegistration"] = setting.Service.AllowOnlyInternalRegistration
270271
ctx.Data["OpenID"] = oid
271272
userName, _ := ctx.Session.Get("openid_determined_username").(string)
272273
if userName != "" {
@@ -328,6 +329,7 @@ func RegisterOpenID(ctx *context.Context) {
328329
ctx.Data["PageIsSignIn"] = true
329330
ctx.Data["PageIsOpenIDRegister"] = true
330331
ctx.Data["EnableOpenIDSignUp"] = setting.Service.EnableOpenIDSignUp
332+
ctx.Data["AllowOnlyInternalRegistration"] = setting.Service.AllowOnlyInternalRegistration
331333
ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
332334
ctx.Data["Captcha"] = context.GetImageCaptcha()
333335
ctx.Data["CaptchaType"] = setting.Service.CaptchaType
@@ -367,6 +369,11 @@ func RegisterOpenIDPost(ctx *context.Context) {
367369
ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
368370
ctx.Data["OpenID"] = oid
369371

372+
if setting.Service.AllowOnlyInternalRegistration {
373+
ctx.Error(http.StatusForbidden)
374+
return
375+
}
376+
370377
if setting.Service.EnableCaptcha {
371378
var valid bool
372379
var err error

templates/user/auth/signup_openid_navbar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<a class="{{if .PageIsOpenIDConnect}}active{{end}} item" href="{{AppSubUrl}}/user/openid/connect">
44
{{.i18n.Tr "auth.openid_connect_title"}}
55
</a>
6-
{{if .EnableOpenIDSignUp}}
6+
{{if and .EnableOpenIDSignUp (not .AllowOnlyInternalRegistration)}}
77
<a class="{{if .PageIsOpenIDRegister}}active{{end}} item" href="{{AppSubUrl}}/user/openid/register">
88
{{.i18n.Tr "auth.openid_register_title"}}
99
</a>

0 commit comments

Comments
 (0)