mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Prevent SSO users from changing their email
This commit is contained in:
@@ -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,6 +451,9 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let submit = null;
|
||||||
|
|
||||||
|
if (this.props.user.auth_service === '') {
|
||||||
inputs.push(
|
inputs.push(
|
||||||
<div key='emailSetting'>
|
<div key='emailSetting'>
|
||||||
<div className='form-group'>
|
<div className='form-group'>
|
||||||
@@ -484,11 +487,24 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
</div>
|
</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,6 +515,7 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let describe = '';
|
let describe = '';
|
||||||
|
if (this.props.user.auth_service === '') {
|
||||||
if (this.state.emailChangeInProgress) {
|
if (this.state.emailChangeInProgress) {
|
||||||
const newEmail = UserStore.getCurrentUser().email;
|
const newEmail = UserStore.getCurrentUser().email;
|
||||||
if (newEmail) {
|
if (newEmail) {
|
||||||
@@ -509,6 +526,9 @@ export default class UserSettingsGeneralTab extends React.Component {
|
|||||||
} else {
|
} else {
|
||||||
describe = UserStore.getCurrentUser().email;
|
describe = UserStore.getCurrentUser().email;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
describe = 'Log in done through GitLab';
|
||||||
|
}
|
||||||
|
|
||||||
emailSection = (
|
emailSection = (
|
||||||
<SettingItemMin
|
<SettingItemMin
|
||||||
|
|||||||
Reference in New Issue
Block a user