-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
email.js
46 lines (36 loc) · 1.11 KB
/
email.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
define('forum/account/edit/email', ['forum/account/header'], function (header) {
var AccountEditEmail = {};
AccountEditEmail.init = function () {
header.init();
$('#submitBtn').on('click', function () {
var curPasswordEl = $('#inputCurrentPassword');
var userData = {
uid: $('#inputUID').val(),
email: $('#inputNewEmail').val(),
password: curPasswordEl.val(),
};
if (!userData.email) {
return;
}
if (userData.email === userData.password) {
curPasswordEl.parents('.control-group').toggleClass('has-error', true);
return app.alertError('[[user:email_same_as_password]]');
}
var btn = $(this);
btn.addClass('disabled').find('i').removeClass('hide');
$.ajax({
url: config.relative_path + '/api/v1/users/' + userData.uid,
data: userData,
method: 'put',
}).done(function (res) {
btn.removeClass('disabled').find('i').addClass('hide');
ajaxify.go('user/' + res.response.userslug + '/edit');
}).fail(function (ev) {
app.alertError(ev.responseJSON.status.message);
});
return false;
});
};
return AccountEditEmail;
});