mirror of
https://hk.gh-proxy.com/https://github.com/NodeBB/nodebb-plugin-sso-oauth2-multiple.git
synced 2025-10-04 04:32:03 +08:00
feat: new option forceUsernameViaEmail
This commit is contained in:
parent
d662fc069f
commit
ac95ec31d4
3 changed files with 8 additions and 3 deletions
|
@ -73,7 +73,7 @@ Controllers.editStrategy = async (req, res) => {
|
|||
|
||||
payload.enabled = !!req.body.enabled;
|
||||
|
||||
const checkboxes = ['usernameViaEmail', 'trustEmailVerified', 'syncFullname', 'syncPicture'];
|
||||
const checkboxes = ['forceUsernameViaEmail', 'usernameViaEmail', 'trustEmailVerified', 'syncFullname', 'syncPicture'];
|
||||
checkboxes.forEach((prop) => {
|
||||
payload[prop] = payload.hasOwnProperty(prop) && payload[prop] === 'on' ? 1 : 0;
|
||||
});
|
||||
|
|
|
@ -166,7 +166,7 @@ OAuth.parseUserReturn = async (provider, profile) => {
|
|||
given_name, middle_name, family_name,
|
||||
picture, roles, email, email_verified,
|
||||
} = profile;
|
||||
const { usernameViaEmail, idKey } = await OAuth.getStrategy(provider);
|
||||
const { usernameViaEmail, forceUsernameViaEmail, idKey } = await OAuth.getStrategy(provider);
|
||||
|
||||
const displayName = nickname || preferred_username || name;
|
||||
|
||||
|
@ -184,7 +184,7 @@ OAuth.parseUserReturn = async (provider, profile) => {
|
|||
email_verified,
|
||||
};
|
||||
|
||||
if (!normalized.displayName && email && usernameViaEmail === 'on') {
|
||||
if (forceUsernameViaEmail || (!normalized.displayName && email && usernameViaEmail === 'on')) {
|
||||
normalized.displayName = email.split('@')[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,11 @@
|
|||
<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>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input type="checkbox" class="form-check-input" id="forceUsernameViaEmail" name="forceUsernameViaEmail" {{{ if (./forceUsernameViaEmail == "1") }}}checked{{{ end }}}>
|
||||
<label for="forceUsernameViaEmail" class="form-check-label">Use email as username <span class="form-text text-danger">(supercedes previous option).</span></label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input type="checkbox" class="form-check-input" id="trustEmailVerified" name="trustEmailVerified" {{{ if (./trustEmailVerified == "1") }}}checked{{{ end }}}>
|
||||
<label for="trustEmailVerified" class="form-check-label">Automatically confirm emails when <code>email_verified</code> is true.</code></label>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue