mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: sso_overrides_(email|username|name) for all auth methods
These settings previously applied only to discourse-sso. Now they work for all external authentication methods.
This commit is contained in:
@@ -2,7 +2,7 @@ import getURL from "discourse-common/lib/get-url";
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { A } from "@ember/array";
|
import { A } from "@ember/array";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { notEmpty, or, not } from "@ember/object/computed";
|
import { notEmpty, and } from "@ember/object/computed";
|
||||||
import Controller, { inject as controller } from "@ember/controller";
|
import Controller, { inject as controller } from "@ember/controller";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||||
@@ -69,7 +69,8 @@ export default Controller.extend(
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
usernameRequired: not("authOptions.omit_username"),
|
usernameDisabled: and("authOptions", "!authOptions.can_edit_username"),
|
||||||
|
nameDisabled: and("authOptions", "!authOptions.can_edit_name"),
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed
|
||||||
fullnameRequired() {
|
fullnameRequired() {
|
||||||
|
|||||||
@@ -389,6 +389,6 @@ export default Controller.extend(ModalFunctionality, {
|
|||||||
authOptions: EmberObject.create(options)
|
authOptions: EmberObject.create(options)
|
||||||
});
|
});
|
||||||
|
|
||||||
showModal("createAccount");
|
showModal("createAccount", { modalClass: "create-account" });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,11 @@
|
|||||||
<tr class="input create-account-email">
|
<tr class="input create-account-email">
|
||||||
<td class="label"><label for="new-account-email">{{i18n "user.email.title"}}</label></td>
|
<td class="label"><label for="new-account-email">{{i18n "user.email.title"}}</label></td>
|
||||||
<td>
|
<td>
|
||||||
{{input type="email" value=accountEmail id="new-account-email" disabled=emailValidated name="email" autofocus="autofocus"}}
|
{{#if emailValidated}}
|
||||||
|
<span class="value">{{accountEmail}}</span>
|
||||||
|
{{else}}
|
||||||
|
{{input type="email" value=accountEmail id="new-account-email" name="email" autofocus="autofocus"}}
|
||||||
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@@ -25,11 +29,14 @@
|
|||||||
<td><label>{{i18n "user.email.instructions"}}</label></td>
|
<td><label>{{i18n "user.email.instructions"}}</label></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{{#if usernameRequired}}
|
|
||||||
<tr class="input">
|
<tr class="input">
|
||||||
<td class="label"><label for="new-account-username">{{i18n "user.username.title"}}</label></td>
|
<td class="label"><label for="new-account-username">{{i18n "user.username.title"}}</label></td>
|
||||||
<td>
|
<td>
|
||||||
|
{{#if usernameDisabled}}
|
||||||
|
<span class="value">{{accountUsername}}</span>
|
||||||
|
{{else}}
|
||||||
{{input value=accountUsername id="new-account-username" name="username" maxlength=maxUsernameLength autocomplete="discourse"}}
|
{{input value=accountUsername id="new-account-username" name="username" maxlength=maxUsernameLength autocomplete="discourse"}}
|
||||||
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="instructions">
|
<tr class="instructions">
|
||||||
@@ -37,7 +44,6 @@
|
|||||||
{{input-tip validation=usernameValidation id="username-validation"}}
|
{{input-tip validation=usernameValidation id="username-validation"}}
|
||||||
<td><label>{{i18n "user.username.instructions"}}</label></td>
|
<td><label>{{i18n "user.username.instructions"}}</label></td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if fullnameRequired}}
|
{{#if fullnameRequired}}
|
||||||
<tr class="input">
|
<tr class="input">
|
||||||
@@ -45,7 +51,11 @@
|
|||||||
<label for="new-account-name">{{i18n "user.name.title"}}</label>
|
<label for="new-account-name">{{i18n "user.name.title"}}</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
{{#if nameDisabled}}
|
||||||
|
<span class="value">{{accountName}}</span>
|
||||||
|
{{else}}
|
||||||
{{text-field value=accountName id="new-account-name"}}
|
{{text-field value=accountName id="new-account-name"}}
|
||||||
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="instructions">
|
<tr class="instructions">
|
||||||
|
|||||||
@@ -69,6 +69,10 @@
|
|||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr.input span.value {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.user-field {
|
.user-field {
|
||||||
> label {
|
> label {
|
||||||
margin-top: 0.75em;
|
margin-top: 0.75em;
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
.has-alt-auth {
|
.has-alt-auth {
|
||||||
.tip,
|
.tip,
|
||||||
td label {
|
td label {
|
||||||
max-width: 250px;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ class Users::OmniauthCallbacksController < ApplicationController
|
|||||||
elsif ScreenedIpAddress.block_admin_login?(user, request.remote_ip)
|
elsif ScreenedIpAddress.block_admin_login?(user, request.remote_ip)
|
||||||
@auth_result.admin_not_allowed_from_ip_address = true
|
@auth_result.admin_not_allowed_from_ip_address = true
|
||||||
elsif Guardian.new(user).can_access_forum? && user.active # log on any account that is active with forum access
|
elsif Guardian.new(user).can_access_forum? && user.active # log on any account that is active with forum access
|
||||||
|
user.save! if @auth_result.apply_user_attributes!
|
||||||
log_on_user(user)
|
log_on_user(user)
|
||||||
Invite.invalidate_for_email(user.email) # invite link can't be used to log in anymore
|
Invite.invalidate_for_email(user.email) # invite link can't be used to log in anymore
|
||||||
session[:authentication] = nil # don't carry around old auth info, perhaps move elsewhere
|
session[:authentication] = nil # don't carry around old auth info, perhaps move elsewhere
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class UserAuthenticator
|
|||||||
@user = user
|
@user = user
|
||||||
@session = session
|
@session = session
|
||||||
if session[:authentication] && session[:authentication].is_a?(Hash)
|
if session[:authentication] && session[:authentication].is_a?(Hash)
|
||||||
@auth_result = Auth::Result.from_session_data(session[:authentication])
|
@auth_result = Auth::Result.from_session_data(session[:authentication], user: user)
|
||||||
end
|
end
|
||||||
@authenticator_finder = authenticator_finder
|
@authenticator_finder = authenticator_finder
|
||||||
end
|
end
|
||||||
@@ -14,6 +14,7 @@ class UserAuthenticator
|
|||||||
def start
|
def start
|
||||||
if authenticated?
|
if authenticated?
|
||||||
@user.active = true
|
@user.active = true
|
||||||
|
@auth_result.apply_user_attributes!
|
||||||
else
|
else
|
||||||
@user.password_required!
|
@user.password_required!
|
||||||
end
|
end
|
||||||
@@ -38,7 +39,10 @@ class UserAuthenticator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def authenticated?
|
def authenticated?
|
||||||
@auth_result && @auth_result.email.downcase == @user.email.downcase && @auth_result.email_valid.to_s == "true"
|
return false if !@auth_result
|
||||||
|
return false if @auth_result.email.downcase != @user.email.downcase
|
||||||
|
return false if @auth_result.email_valid != true # strong check for truth, in case we have another object type
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -1632,9 +1632,9 @@ en:
|
|||||||
sso_provider_secrets: "A list of domain-secret pairs that are using Discourse as an SSO provider. Make sure SSO secret is 10 characters or longer. Wildcard symbol * can be used to match any domain or only a part of it (e.g. *.example.com)."
|
sso_provider_secrets: "A list of domain-secret pairs that are using Discourse as an SSO provider. Make sure SSO secret is 10 characters or longer. Wildcard symbol * can be used to match any domain or only a part of it (e.g. *.example.com)."
|
||||||
sso_overrides_bio: "Overrides user bio in user profile and prevents user from changing it"
|
sso_overrides_bio: "Overrides user bio in user profile and prevents user from changing it"
|
||||||
sso_overrides_groups: "Synchronize all manual group membership with groups specified in the groups sso attribute (WARNING: if you do not specify groups all manual group membership will be cleared for user)"
|
sso_overrides_groups: "Synchronize all manual group membership with groups specified in the groups sso attribute (WARNING: if you do not specify groups all manual group membership will be cleared for user)"
|
||||||
sso_overrides_email: "Overrides local email with external site email from SSO payload on every login, and prevent local changes. (WARNING: discrepancies can occur due to normalization of local emails)"
|
sso_overrides_email: "Overrides local email with external site email from SSO payload on every login, and prevent local changes. Applies to all authentication providers. (WARNING: discrepancies can occur due to normalization of local emails)"
|
||||||
sso_overrides_username: "Overrides local username with external site username from SSO payload on every login, and prevent local changes. (WARNING: discrepancies can occur due to differences in username length/requirements)"
|
sso_overrides_username: "Overrides local username with external site username from SSO payload on every login, and prevent local changes. Applies to all authentication providers. (WARNING: discrepancies can occur due to differences in username length/requirements)"
|
||||||
sso_overrides_name: "Overrides local full name with external site full name from SSO payload on every login, and prevent local changes."
|
sso_overrides_name: "Overrides local full name with external site full name from SSO payload on every login, and prevent local changes. Applies to all authentication providers."
|
||||||
sso_overrides_avatar: "Overrides user avatar with external site avatar from SSO payload. If enabled, users will not be allowed to upload avatars on Discourse."
|
sso_overrides_avatar: "Overrides user avatar with external site avatar from SSO payload. If enabled, users will not be allowed to upload avatars on Discourse."
|
||||||
sso_overrides_location: "Overrides user location with external location from SSO payload and prevent local changes."
|
sso_overrides_location: "Overrides user location with external location from SSO payload and prevent local changes."
|
||||||
sso_overrides_website: "Overrides user website with external location from SSO payload and prevent local changes."
|
sso_overrides_website: "Overrides user website with external location from SSO payload and prevent local changes."
|
||||||
@@ -2244,7 +2244,6 @@ en:
|
|||||||
user_locale_not_enabled: "You must first enable 'allow user locale' before enabling this setting."
|
user_locale_not_enabled: "You must first enable 'allow user locale' before enabling this setting."
|
||||||
invalid_regex: "Regex is invalid or not allowed."
|
invalid_regex: "Regex is invalid or not allowed."
|
||||||
email_editable_enabled: "You must disable 'email editable' before enabling this setting."
|
email_editable_enabled: "You must disable 'email editable' before enabling this setting."
|
||||||
enable_sso_disabled: "You must first enable 'enable sso' before enabling this setting."
|
|
||||||
staged_users_disabled: "You must first enable 'staged users' before enabling this setting."
|
staged_users_disabled: "You must first enable 'staged users' before enabling this setting."
|
||||||
reply_by_email_disabled: "You must first enable 'reply by email' before enabling this setting."
|
reply_by_email_disabled: "You must first enable 'reply by email' before enabling this setting."
|
||||||
sso_url_is_empty: "You must set a 'sso url' before enabling this setting."
|
sso_url_is_empty: "You must set a 'sso url' before enabling this setting."
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Auth::Result
|
|||||||
:requires_invite,
|
:requires_invite,
|
||||||
:not_allowed_from_ip_address,
|
:not_allowed_from_ip_address,
|
||||||
:admin_not_allowed_from_ip_address,
|
:admin_not_allowed_from_ip_address,
|
||||||
:omit_username,
|
:omit_username, # Used by plugins to prevent username edits
|
||||||
:skip_email_validation,
|
:skip_email_validation,
|
||||||
:destination_url,
|
:destination_url,
|
||||||
:omniauth_disallow_totp,
|
:omniauth_disallow_totp,
|
||||||
@@ -60,13 +60,42 @@ class Auth::Result
|
|||||||
SESSION_ATTRIBUTES.map { |att| [att, public_send(att)] }.to_h
|
SESSION_ATTRIBUTES.map { |att| [att, public_send(att)] }.to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_session_data(data)
|
def self.from_session_data(data, user:)
|
||||||
result = new
|
result = new
|
||||||
data = data.symbolize_keys
|
data = data.symbolize_keys
|
||||||
SESSION_ATTRIBUTES.each { |att| result.public_send("#{att}=", data[att]) }
|
SESSION_ATTRIBUTES.each { |att| result.public_send("#{att}=", data[att]) }
|
||||||
|
result.user = user
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apply_user_attributes!
|
||||||
|
change_made = false
|
||||||
|
if SiteSetting.sso_overrides_username? && username.present? && username != user.username
|
||||||
|
user.username = UserNameSuggester.suggest(username || name || email, user.username)
|
||||||
|
change_made = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if SiteSetting.sso_overrides_email && email_valid && email.present? && user.email != Email.downcase(email)
|
||||||
|
user.email = email
|
||||||
|
change_made = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if SiteSetting.sso_overrides_name && name.present? && user.name != name
|
||||||
|
user.name = name
|
||||||
|
change_made = true
|
||||||
|
end
|
||||||
|
|
||||||
|
change_made
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_edit_name
|
||||||
|
!SiteSetting.sso_overrides_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_edit_username
|
||||||
|
!(SiteSetting.sso_overrides_username || omit_username)
|
||||||
|
end
|
||||||
|
|
||||||
def to_client_hash
|
def to_client_hash
|
||||||
if requires_invite
|
if requires_invite
|
||||||
return { requires_invite: true }
|
return { requires_invite: true }
|
||||||
@@ -106,13 +135,15 @@ class Auth::Result
|
|||||||
username: UserNameSuggester.suggest(username || name || email),
|
username: UserNameSuggester.suggest(username || name || email),
|
||||||
auth_provider: authenticator_name,
|
auth_provider: authenticator_name,
|
||||||
email_valid: !!email_valid,
|
email_valid: !!email_valid,
|
||||||
omit_username: !!omit_username
|
can_edit_username: can_edit_username,
|
||||||
|
can_edit_name: can_edit_name
|
||||||
}
|
}
|
||||||
|
|
||||||
result[:destination_url] = destination_url if destination_url.present?
|
result[:destination_url] = destination_url if destination_url.present?
|
||||||
|
|
||||||
if SiteSetting.enable_names?
|
if SiteSetting.enable_names?
|
||||||
result[:name] = name.presence || User.suggest_name(username || email)
|
result[:name] = name.presence
|
||||||
|
result[:name] ||= User.suggest_name(username || email) if can_edit_name
|
||||||
end
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ module UserGuardian
|
|||||||
end
|
end
|
||||||
|
|
||||||
def can_edit_username?(user)
|
def can_edit_username?(user)
|
||||||
return false if SiteSetting.sso_overrides_username? && SiteSetting.enable_sso?
|
return false if SiteSetting.sso_overrides_username?
|
||||||
return true if is_staff?
|
return true if is_staff?
|
||||||
return false if SiteSetting.username_change_period <= 0
|
return false if SiteSetting.username_change_period <= 0
|
||||||
return false if is_anonymous?
|
return false if is_anonymous?
|
||||||
@@ -31,7 +31,7 @@ module UserGuardian
|
|||||||
end
|
end
|
||||||
|
|
||||||
def can_edit_email?(user)
|
def can_edit_email?(user)
|
||||||
return false if SiteSetting.sso_overrides_email? && SiteSetting.enable_sso?
|
return false if SiteSetting.sso_overrides_email?
|
||||||
return false unless SiteSetting.email_editable?
|
return false unless SiteSetting.email_editable?
|
||||||
return true if is_staff?
|
return true if is_staff?
|
||||||
return false if is_anonymous?
|
return false if is_anonymous?
|
||||||
@@ -40,7 +40,7 @@ module UserGuardian
|
|||||||
|
|
||||||
def can_edit_name?(user)
|
def can_edit_name?(user)
|
||||||
return false unless SiteSetting.enable_names?
|
return false unless SiteSetting.enable_names?
|
||||||
return false if SiteSetting.sso_overrides_name? && SiteSetting.enable_sso?
|
return false if SiteSetting.sso_overrides_name?
|
||||||
return true if is_staff?
|
return true if is_staff?
|
||||||
return false if is_anonymous?
|
return false if is_anonymous?
|
||||||
can_edit?(user)
|
can_edit?(user)
|
||||||
|
|||||||
@@ -7,15 +7,12 @@ class SsoOverridesEmailValidator
|
|||||||
|
|
||||||
def valid_value?(val)
|
def valid_value?(val)
|
||||||
return true if val == 'f'
|
return true if val == 'f'
|
||||||
return false if !SiteSetting.enable_sso?
|
|
||||||
return false if SiteSetting.email_editable?
|
return false if SiteSetting.email_editable?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_message
|
def error_message
|
||||||
if !SiteSetting.enable_sso?
|
if SiteSetting.email_editable?
|
||||||
I18n.t('site_settings.errors.enable_sso_disabled')
|
|
||||||
elsif SiteSetting.email_editable?
|
|
||||||
I18n.t('site_settings.errors.email_editable_enabled')
|
I18n.t('site_settings.errors.email_editable_enabled')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -49,27 +49,5 @@ RSpec.describe SsoOverridesEmailValidator do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when 'enable sso' is false" do
|
|
||||||
before do
|
|
||||||
SiteSetting.enable_sso = false
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'when value is false' do
|
|
||||||
it 'should be valid' do
|
|
||||||
expect(subject.valid_value?('f')).to eq(true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'when value is true' do
|
|
||||||
it 'should not be valid' do
|
|
||||||
expect(subject.valid_value?('t')).to eq(false)
|
|
||||||
|
|
||||||
expect(subject.error_message).to eq(I18n.t(
|
|
||||||
'site_settings.errors.enable_sso_disabled'
|
|
||||||
))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ RSpec.describe Users::OmniauthCallbacksController do
|
|||||||
expect(data["username"]).to eq("Some_Name")
|
expect(data["username"]).to eq("Some_Name")
|
||||||
expect(data["auth_provider"]).to eq("google_oauth2")
|
expect(data["auth_provider"]).to eq("google_oauth2")
|
||||||
expect(data["email_valid"]).to eq(true)
|
expect(data["email_valid"]).to eq(true)
|
||||||
expect(data["omit_username"]).to eq(false)
|
expect(data["can_edit_username"]).to eq(true)
|
||||||
expect(data["name"]).to eq("Some Name")
|
expect(data["name"]).to eq("Some Name")
|
||||||
expect(data["destination_url"]).to eq(destination_url)
|
expect(data["destination_url"]).to eq(destination_url)
|
||||||
end
|
end
|
||||||
@@ -229,7 +229,8 @@ RSpec.describe Users::OmniauthCallbacksController do
|
|||||||
uid: '123545',
|
uid: '123545',
|
||||||
info: OmniAuth::AuthHash::InfoHash.new(
|
info: OmniAuth::AuthHash::InfoHash.new(
|
||||||
email: user.email,
|
email: user.email,
|
||||||
name: 'Some name'
|
name: 'Some name',
|
||||||
|
nickname: 'Somenickname'
|
||||||
),
|
),
|
||||||
extra: {
|
extra: {
|
||||||
raw_info: OmniAuth::AuthHash.new(
|
raw_info: OmniAuth::AuthHash.new(
|
||||||
@@ -347,6 +348,44 @@ RSpec.describe Users::OmniauthCallbacksController do
|
|||||||
expect(user.confirm_password?("securepassword")).to eq(false)
|
expect(user.confirm_password?("securepassword")).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should update name/username/email when sso_overrides is enabled" do
|
||||||
|
SiteSetting.email_editable = false
|
||||||
|
SiteSetting.sso_overrides_email = true
|
||||||
|
SiteSetting.sso_overrides_name = true
|
||||||
|
SiteSetting.sso_overrides_username = true
|
||||||
|
|
||||||
|
UserAssociatedAccount.create!(provider_name: "google_oauth2", user_id: user.id, provider_uid: '123545')
|
||||||
|
|
||||||
|
old_email = user.email
|
||||||
|
user.update!(name: 'somename', username: 'somusername', email: 'email@example.com')
|
||||||
|
|
||||||
|
get "/auth/google_oauth2/callback.json"
|
||||||
|
expect(response.status).to eq(302)
|
||||||
|
|
||||||
|
user.reload
|
||||||
|
expect(user.email).to eq(old_email)
|
||||||
|
expect(user.username).to eq('Somenickname')
|
||||||
|
expect(user.name).to eq('Some name')
|
||||||
|
end
|
||||||
|
|
||||||
|
it "will not update email if not verified" do
|
||||||
|
SiteSetting.email_editable = false
|
||||||
|
SiteSetting.sso_overrides_email = true
|
||||||
|
|
||||||
|
OmniAuth.config.mock_auth[:google_oauth2][:extra][:raw_info][:email_verified] = false
|
||||||
|
|
||||||
|
UserAssociatedAccount.create!(provider_name: "google_oauth2", user_id: user.id, provider_uid: '123545')
|
||||||
|
|
||||||
|
old_email = user.email
|
||||||
|
user.update!(email: 'email@example.com')
|
||||||
|
|
||||||
|
get "/auth/google_oauth2/callback.json"
|
||||||
|
expect(response.status).to eq(302)
|
||||||
|
|
||||||
|
user.reload
|
||||||
|
expect(user.email).to eq('email@example.com')
|
||||||
|
end
|
||||||
|
|
||||||
context 'when user has TOTP enabled' do
|
context 'when user has TOTP enabled' do
|
||||||
before do
|
before do
|
||||||
user.create_totp(enabled: true)
|
user.create_totp(enabled: true)
|
||||||
|
|||||||
@@ -984,7 +984,8 @@ describe UsersController do
|
|||||||
uid: '123545',
|
uid: '123545',
|
||||||
info: OmniAuth::AuthHash::InfoHash.new(
|
info: OmniAuth::AuthHash::InfoHash.new(
|
||||||
email: "osama@mail.com",
|
email: "osama@mail.com",
|
||||||
nickname: "testosama"
|
nickname: "testosama",
|
||||||
|
name: "Osama Test"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1036,6 +1037,24 @@ describe UsersController do
|
|||||||
json = response.parsed_body
|
json = response.parsed_body
|
||||||
expect(json['success']).to eq(true)
|
expect(json['success']).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't use provided username/name if sso_overrides is enabled" do
|
||||||
|
SiteSetting.sso_overrides_username = true
|
||||||
|
SiteSetting.sso_overrides_name = true
|
||||||
|
post "/u.json", params: {
|
||||||
|
username: "attemptednewname",
|
||||||
|
name: "Attempt At New Name",
|
||||||
|
password: "strongpassword",
|
||||||
|
email: "osama@mail.com"
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
json = response.parsed_body
|
||||||
|
expect(json['success']).to eq(true)
|
||||||
|
expect(User.last.username).to eq('testosama')
|
||||||
|
expect(User.last.name).to eq('Osama Test')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user