diff --git a/frontend/src/components/siteComponents/UserSettingsUI/index.js b/frontend/src/components/siteComponents/UserSettingsUI/index.js index a0c05cb6..f3c51d95 100644 --- a/frontend/src/components/siteComponents/UserSettingsUI/index.js +++ b/frontend/src/components/siteComponents/UserSettingsUI/index.js @@ -75,13 +75,14 @@ class UserSettingsUI extends Component { allotment: '', confirmUser: '', currPassword: '', - privateColl: null, - indexColl: null, desc: props.user.get('desc'), display_url: props.user.get('display_url'), full_name: props.user.get('full_name'), + indexColl: null, + newEmail: '', password: '', password2: '', + privateColl: null, reIndexColl: false, role: null, showModal: false @@ -183,6 +184,15 @@ class UserSettingsUI extends Component { adminUpdateUser(user, { role: 'suspended' }); } + updateEmail = () => { + const { match: { params: { user } }, adminUpdateUser } = this.props; + const { newEmail } = this.state; + + if (this.validateEmail()) { + adminUpdateUser(user, { email_addr: newEmail }); + } + } + updateUserAllotment = () => { const { match: { params: { user } }, adminUpdateUser } = this.props; const { allotment } = this.state; @@ -230,6 +240,16 @@ class UserSettingsUI extends Component { return true; } + validateEmail = () => { + const { newEmail } = this.state; + + if (!newEmail || newEmail.indexOf('@') === -1 || newEmail.match(/\.\w+$/) === null) { + return false; + } + + return true; + } + validatePassword = () => { const { password, password2, missingPw } = this.state; @@ -388,6 +408,22 @@ class UserSettingsUI extends Component { +
+
Update Email
+ + + 6 && !this.validateEmail()} + value={this.state.newEmail} /> + + + +
diff --git a/webrecorder/webrecorder/models/usermanager.py b/webrecorder/webrecorder/models/usermanager.py index 6a39ea1c..c9da951d 100644 --- a/webrecorder/webrecorder/models/usermanager.py +++ b/webrecorder/webrecorder/models/usermanager.py @@ -661,6 +661,9 @@ def update_user_as_admin(self, user, data): if 'customer_max_size' in data: user['customer_max_size'] = data['customer_max_size'] + if 'email_addr' in data: + user['email_addr'] = data['email_addr'] + return None def delete_user(self, username):