Merge pull request #1332 from mattermost/plt-560
PLT-560 Prevent SSO users from changing their email
Этот коммит содержится в:
@@ -114,7 +114,7 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
sendWelcomeEmail = false
|
sendWelcomeEmail = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(user.AuthData) > 0 && len(user.AuthService) > 0 {
|
if user.IsSSOUser() {
|
||||||
user.EmailVerified = true
|
user.EmailVerified = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -326,6 +326,13 @@ func IsInRole(userRoles string, inRole string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *User) IsSSOUser() bool {
|
||||||
|
if len(u.AuthData) != 0 && len(u.AuthService) != 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (u *User) PreExport() {
|
func (u *User) PreExport() {
|
||||||
u.Password = ""
|
u.Password = ""
|
||||||
u.AuthData = ""
|
u.AuthData = ""
|
||||||
|
|||||||
@@ -140,7 +140,9 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha
|
|||||||
user.DeleteAt = oldUser.DeleteAt
|
user.DeleteAt = oldUser.DeleteAt
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Email != oldUser.Email {
|
if user.IsSSOUser() {
|
||||||
|
user.Email = oldUser.Email
|
||||||
|
} else if user.Email != oldUser.Email {
|
||||||
user.EmailVerified = false
|
user.EmailVerified = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -451,44 +451,60 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs.push(
|
let submit = null;
|
||||||
<div key='emailSetting'>
|
|
||||||
<div className='form-group'>
|
|
||||||
<label className='col-sm-5 control-label'>{'Primary Email'}</label>
|
|
||||||
<div className='col-sm-7'>
|
|
||||||
<input
|
|
||||||
className='form-control'
|
|
||||||
type='text'
|
|
||||||
onChange={this.updateEmail}
|
|
||||||
value={this.state.email}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
inputs.push(
|
if (this.props.user.auth_service === '') {
|
||||||
<div key='confirmEmailSetting'>
|
inputs.push(
|
||||||
<div className='form-group'>
|
<div key='emailSetting'>
|
||||||
<label className='col-sm-5 control-label'>{'Confirm Email'}</label>
|
<div className='form-group'>
|
||||||
<div className='col-sm-7'>
|
<label className='col-sm-5 control-label'>{'Primary Email'}</label>
|
||||||
<input
|
<div className='col-sm-7'>
|
||||||
className='form-control'
|
<input
|
||||||
type='text'
|
className='form-control'
|
||||||
onChange={this.updateConfirmEmail}
|
type='text'
|
||||||
value={this.state.confirmEmail}
|
onChange={this.updateEmail}
|
||||||
/>
|
value={this.state.email}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{helpText}
|
);
|
||||||
</div>
|
|
||||||
);
|
inputs.push(
|
||||||
|
<div key='confirmEmailSetting'>
|
||||||
|
<div className='form-group'>
|
||||||
|
<label className='col-sm-5 control-label'>{'Confirm Email'}</label>
|
||||||
|
<div className='col-sm-7'>
|
||||||
|
<input
|
||||||
|
className='form-control'
|
||||||
|
type='text'
|
||||||
|
onChange={this.updateConfirmEmail}
|
||||||
|
value={this.state.confirmEmail}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{helpText}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
submit = this.submitEmail;
|
||||||
|
} else {
|
||||||
|
inputs.push(
|
||||||
|
<div
|
||||||
|
key='oauthEmailInfo'
|
||||||
|
className='form-group'
|
||||||
|
>
|
||||||
|
<div className='setting-list__hint'>{'Log in occurs through GitLab. Email cannot be updated.'}</div>
|
||||||
|
{helpText}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
emailSection = (
|
emailSection = (
|
||||||
<SettingItemMax
|
<SettingItemMax
|
||||||
title='Email'
|
title='Email'
|
||||||
inputs={inputs}
|
inputs={inputs}
|
||||||
submit={this.submitEmail}
|
submit={submit}
|
||||||
server_error={serverError}
|
server_error={serverError}
|
||||||
client_error={emailError}
|
client_error={emailError}
|
||||||
updateSection={function clearSection(e) {
|
updateSection={function clearSection(e) {
|
||||||
@@ -499,15 +515,19 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let describe = '';
|
let describe = '';
|
||||||
if (this.state.emailChangeInProgress) {
|
if (this.props.user.auth_service === '') {
|
||||||
const newEmail = UserStore.getCurrentUser().email;
|
if (this.state.emailChangeInProgress) {
|
||||||
if (newEmail) {
|
const newEmail = UserStore.getCurrentUser().email;
|
||||||
describe = 'New Address: ' + newEmail + '\nCheck your email to verify the above address.';
|
if (newEmail) {
|
||||||
|
describe = 'New Address: ' + newEmail + '\nCheck your email to verify the above address.';
|
||||||
|
} else {
|
||||||
|
describe = 'Check your email to verify your new address';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
describe = 'Check your email to verify your new address';
|
describe = UserStore.getCurrentUser().email;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
describe = UserStore.getCurrentUser().email;
|
describe = 'Log in done through GitLab';
|
||||||
}
|
}
|
||||||
|
|
||||||
emailSection = (
|
emailSection = (
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user