Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,31 @@ OAuth application secret | `abcdefghijABCDEFGHIJabcdefghijABCDEFGHIJ` | The *Cli
OAuth scopes to request | | Optional additional scopes to request during authorization, perhaps you want to protect the user url with a scope or add additional functionality
Label for login button | Login with Example | Label to place on the login button
Icon for login button | `far fa-id-card` | FontAwesome icon to place on the login button. [List of available icons](https://fontawesome.com/icons?m=free)
OAuth User ID field name | `id` | **Required.** The field name in the OAuth user response that contains the user ID
OAuth User email field name | `email` | **Required.** The field name in the OAuth user response that contains the user email
OAuth User name field name | `name` | **Optional.** The field name in the OAuth user response that contains the user name. Note: This field is not currently used by Flarum for authentication

**Hint:** When creating the OAuth client in your Laravel app, don't forget to set the `redirect` value to `<your flarum install>/auth/passport` or you might encounter `invalid_client` errors.

### Field Mapping

The new field mapping settings allow you to customize which fields from your OAuth provider's user response are used for user identification. This is useful when your OAuth API returns user data with different field names than the defaults.

**Example:** If your OAuth API returns:
```json
{
"user_id": 123,
"user_email": "john@example.com",
"user_fullname": "John Doe"
}
```

You would configure:
- OAuth User ID field name: `user_id`
- OAuth User email field name: `user_email`
- OAuth User name field name: `user_fullname`


## Links

- [Flarum Discuss post](https://discuss.flarum.org/d/5203)
Expand Down
2 changes: 1 addition & 1 deletion js/dist/admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/admin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions js/src/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,23 @@ app.initializers.add('fof-passport', function () {
setting: 'fof-passport.button_icon',
type: 'text',
placeholder: 'far fa-id-card',
})
.registerSetting({
label: app.translator.trans('fof-passport.admin.popup.field.user-id-field'),
setting: 'fof-passport.user_id_field',
type: 'text',
placeholder: 'id',
})
.registerSetting({
label: app.translator.trans('fof-passport.admin.popup.field.user-email-field'),
setting: 'fof-passport.user_email_field',
type: 'text',
placeholder: 'email',
})
.registerSetting({
label: app.translator.trans('fof-passport.admin.popup.field.user-name-field'),
setting: 'fof-passport.user_name_field',
type: 'text',
placeholder: 'name',
});
});
3 changes: 3 additions & 0 deletions locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ fof-passport:
button-title: Label for login button
button-title-placeholder: => fof-passport.api.default-login-button-title
button-icon: Icon for login button
user-id-field: OAuth User ID field name
user-email-field: OAuth User email field name
user-name-field: OAuth User name field name

api:
default-login-button-title: => core.ref.log_in
Loading
Loading