Skip to content

Commit 852031b

Browse files
committed
feat: add another adjustment to allow for an override for the id key
1 parent 9dcbff7 commit 852031b

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

library.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ OAuth.parseUserReturn = async (provider, profile) => {
157157
id, sub, name, nickname, preferred_username, picture,
158158
email, /* , email_verified */
159159
} = profile;
160-
const { usernameViaEmail } = await OAuth.getStrategy(provider);
160+
const { usernameViaEmail, idKey } = await OAuth.getStrategy(provider);
161161
const normalized = {
162162
provider,
163-
id: id || sub,
163+
id: profile[idKey] || id || sub,
164164
displayName: nickname || preferred_username || name,
165165
picture,
166166
email,

static/templates/partials/edit-oauth2-strategy.tpl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,20 @@
9999
We offer some common adjustments below.
100100
</p>
101101

102-
<div class="form-check form-switch">
102+
<div class="form-check form-switch mb-3">
103103
<input type="checkbox" class="form-check-input" id="usernameViaEmail" name="usernameViaEmail" {{{ if (./usernameViaEmail == "on") }}}checked{{{ end }}}>
104104
<label for="usernameViaEmail" class="form-check-label">Fall back to email as username if no username available (e.g. <code><strong>username</strong>@example.org</code>)</label>
105105
</div>
106+
107+
<div class="mb-3">
108+
<label class="form-label" for="idKey">Alternative <code>id</code> key</label>
109+
<input type="text" id="idKey" name="idKey" title="Alternative id key" class="form-control" placeholder="e.g. auth0Id" value="{./idKey}">
110+
<p class="form-text">
111+
The properties <code>id</code> and <code>sub</code> are normally used.
112+
In case you wish to use an alternative key returned in the User Info URL as the key, enter it here.
113+
If that field is empty or missing, then we will fall back to the defaults.
114+
</p>
115+
</div>
106116
</div>
107117
</div>
108118
</form>

0 commit comments

Comments
 (0)