|
136 | 136 | states: @json($states), |
137 | 137 | status: @json($status), |
138 | 138 | global2FAEnabled: @json($global2FAEnabled), |
| 139 | + ssoUser:@json($ssoUser), |
139 | 140 | errors: { |
140 | 141 | username: null, |
141 | 142 | firstname: null, |
|
146 | 147 | }, |
147 | 148 | confPassword: '', |
148 | 149 | image: '', |
| 150 | + originalEmail: '', |
| 151 | + emailHasChanged: false, |
149 | 152 | options: [ |
150 | 153 | { |
151 | 154 | src: @json($currentUser['avatar']), |
|
169 | 172 | }); |
170 | 173 | } |
171 | 174 | }, |
| 175 | + mounted() { |
| 176 | + this.originalEmail = this.formData.email; |
| 177 | + }, |
172 | 178 | methods: { |
173 | 179 | openAvatarModal() { |
174 | 180 | modalVueInstance.$refs.updateAvatarModal.show(); |
175 | 181 | }, |
176 | 182 | profileUpdate() { |
177 | | - this.resetErrors(); |
178 | | - if (@json($enabled2FA) && this.global2FAEnabled.length === 0) { |
179 | | - let message = 'The Two Step Authentication Method has not been set. ' + |
180 | | - 'Please contact your administrator.'; |
181 | | - // User has not enabled two-factor authentication correctly |
182 | | - ProcessMaker.alert(this.$t($message), 'warning'); |
183 | | - return false; |
184 | | - } |
185 | | - if (!this.validatePassword()) return false; |
186 | | - if (@json($enabled2FA) && typeof this.formData.preferences_2fa != "undefined" && |
187 | | - this.formData.preferences_2fa != null && this.formData.preferences_2fa.length < 1) |
188 | | - return false; |
189 | | - if (this.image) { |
190 | | - this.formData.avatar = this.image; |
191 | | - } |
192 | | - if (this.image === false) { |
193 | | - this.formData.avatar = false; |
194 | | - } |
195 | | - ProcessMaker.apiClient.put('users/' + this.formData.id, this.formData) |
196 | | - .then((response) => { |
197 | | - ProcessMaker.alert(this.$t('Your profile was saved.'), 'success') |
198 | | - window.ProcessMaker.events.$emit('update-profile-avatar'); |
199 | | - }) |
200 | | - .catch(error => { |
201 | | - this.errors = error.response.data.errors; |
202 | | - }); |
| 183 | + if(this.emailHasChanged && !this.ssoUser) { |
| 184 | + $('#validateModal').modal('show'); |
| 185 | + } else { |
| 186 | + this.saveProfileChanges(); |
| 187 | + } |
203 | 188 | }, |
204 | 189 | deleteAvatar() { |
205 | 190 | let optionValues = formVueInstance.$data.options[0]; |
|
242 | 227 | onClose() { |
243 | 228 | window.location.href = '/admin/users'; |
244 | 229 | }, |
| 230 | + showModal() { |
| 231 | + $('#validateModal').modal('show'); |
| 232 | + }, |
| 233 | + closeModal() { |
| 234 | + $('#validateModal').modal('hide'); |
| 235 | + }, |
| 236 | + saveProfileChanges() { |
| 237 | + this.resetErrors(); |
| 238 | + if (@json($enabled2FA) && this.global2FAEnabled.length === 0) { |
| 239 | + let message = 'The Two Step Authentication Method has not been set. ' + |
| 240 | + 'Please contact your administrator.'; |
| 241 | + // User has not enabled two-factor authentication correctly |
| 242 | + ProcessMaker.alert(this.$t($message), 'warning'); |
| 243 | + return false; |
| 244 | + } |
| 245 | + if (!this.validatePassword()) return false; |
| 246 | + if (@json($enabled2FA) && typeof this.formData.preferences_2fa != "undefined" && |
| 247 | + this.formData.preferences_2fa != null && this.formData.preferences_2fa.length < 1) |
| 248 | + return false; |
| 249 | + if (this.image) { |
| 250 | + this.formData.avatar = this.image; |
| 251 | + } |
| 252 | + if (this.image === false) { |
| 253 | + this.formData.avatar = false; |
| 254 | + } |
| 255 | + ProcessMaker.apiClient.put('users/' + this.formData.id, this.formData) |
| 256 | + .then((response) => { |
| 257 | + ProcessMaker.alert(this.$t('Your profile was saved.'), 'success') |
| 258 | + window.ProcessMaker.events.$emit('update-profile-avatar'); |
| 259 | + this.originalEmail = this.formData.email; |
| 260 | + }) |
| 261 | + .catch(error => { |
| 262 | + this.errors = error.response.data.errors; |
| 263 | + }); |
| 264 | +
|
| 265 | + this.closeModal(); |
| 266 | + }, |
| 267 | + checkEmailChange() { |
| 268 | + this.emailHasChanged = this.formData.email !== this.originalEmail; |
| 269 | + }, |
245 | 270 | }, |
246 | 271 | computed: { |
247 | 272 | state2FA() { |
|
379 | 404 |
|
380 | 405 | //TODO: HANDLE CONNECTION UPDATE |
381 | 406 | this.onCloseModal; |
382 | | - } |
| 407 | + }, |
383 | 408 | } |
384 | 409 | }); |
385 | 410 | </script> |
|
0 commit comments