Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

FEATURE: Allow specifiying required paths when retrieving userinfo#96

Merged
nattsw merged 2 commits intomainfromoauth-required-path
Jan 31, 2024

Conversation

@nattsw
Copy link
Contributor

@nattswnattsw commentedJan 31, 2024
edited
Loading

When retrievinguserinfo withoauth2_fetch_user_details=true, we sometimes want to disallow account creation if an attribute is not fulfilled.

This PR adds a new registeroauth2_basic_required_json_path which will kick in when retrievinguserinfo. It can be used this way:

DiscoursePluginRegistry.register_oauth2_basic_required_json_path({      path: "extra:account.is_allowed_member",      required_value: true,      error_message: I18n.t("login.unfulfilled_requirement"),    }, self)

If the attribute does not satisfy the required value, we will see the specified error message when returning to the forum. The account is not created.

Screenshot 2024-01-31 at 12 45 44 PM

Alternatives

The alternatives I can think of is

  1. monkey patching
  2. creating a new authenticator

(1) is definitely brittle, and (2) does feel like there will be a lot of copy-work even within the method itself.

  1. David did point outon(:after_auth) exists. However the event happens slightly too late - the associated account would have been created already, and theresult would not contain the required attribute.

@nattswnattsw merged commit895db12 intomainJan 31, 2024
@nattswnattsw deleted the oauth-required-path branchJanuary 31, 2024 12:19
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

1 more reviewer

@davidtaylorhqdavidtaylorhqdavidtaylorhq approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@nattsw@davidtaylorhq

[8]ページ先頭

©2009-2025 Movatter.jp