Resend verification email menu entry

upd4.2
Bernat Romagosa 2018-02-12 16:29:30 +01:00
rodzic df66f6ae93
commit 60c7c91969
3 zmienionych plików z 57 dodań i 8 usunięć

Wyświetl plik

@ -321,13 +321,24 @@ Cloud.prototype.changePassword = function (
Cloud.prototype.resetPassword = function (username, onSuccess, onError) {
this.request(
'POST',
'/users/' + username + '/resetpassword',
'/users/' + username + '/password_reset',
onSuccess,
onError,
'Password reset request failed'
);
};
Cloud.prototype.resendVerification = function (username, onSuccess, onError) {
this.request(
'POST',
'/users/' + username + '/resendverification',
onSuccess,
onError,
'Could not send verification email'
);
};
// Projects
Cloud.prototype.saveProject = function (ide, onSuccess, onError) {

46
gui.js
Wyświetl plik

@ -2519,6 +2519,10 @@ IDE_Morph.prototype.cloudMenu = function () {
'Reset Password...',
'resetCloudPassword'
);
menu.addItem(
'Resend Verification Email...',
'resendVerification'
);
} else {
menu.addItem(
localize('Logout') + ' ' + SnapCloud.username,
@ -5140,7 +5144,7 @@ IDE_Morph.prototype.initializeCloud = function () {
user.choice,
function (username, isadmin, response) {
myself.source = 'cloud';
if (response.days_left) {
if (!isNil(response.days_left)) {
new DialogBoxMorph().inform(
'Unverified account: ' + response.days_left + ' days left',
'You are now logged in, but your account\n' +
@ -5248,6 +5252,43 @@ IDE_Morph.prototype.resetCloudPassword = function () {
);
};
IDE_Morph.prototype.resendVerification = function () {
var myself = this,
world = this.world();
new DialogBoxMorph(
null,
function (user) {
SnapCloud.resendVerification(
user.username,
function (txt, title) {
new DialogBoxMorph().inform(
title,
txt +
'.\n\nAn e-mail with a link to\n' +
'verify your account\n' +
'has been sent to the address provided',
world,
myself.cloudIcon(null, new Color(0, 180, 0))
);
},
myself.cloudError()
);
}
).withKey('cloudresendverification').promptCredentials(
'Resend verification email',
'resendVerification',
null,
null,
null,
null,
null,
world,
myself.cloudIcon(),
myself.cloudMsg
);
};
IDE_Morph.prototype.changeCloudPassword = function () {
var myself = this,
world = this.world();
@ -5459,9 +5500,6 @@ IDE_Morph.prototype.cloudError = function () {
myself.showMessage(explanation);
return;
}
if (response.length > 50) {
response = response.substring(0, 50) + '...';
}
new DialogBoxMorph().inform(
'Snap!Cloud',
(url ? url + '\n' : '')

Wyświetl plik

@ -2095,7 +2095,7 @@ DialogBoxMorph.prototype.promptCredentials = function (
inp.add(pw2);
}
if (purpose === 'resetPassword') {
if (purpose === 'resetPassword' || purpose === 'resendVerification') {
inp.add(labelText('User name:'));
inp.add(usr);
}
@ -2189,7 +2189,7 @@ DialogBoxMorph.prototype.promptCredentials = function (
checklist = [usr, bmn, byr, eml, pw1, pw2];
} else if (purpose === 'changePassword') {
checklist = [opw, pw1, pw2];
} else if (purpose === 'resetPassword') {
} else if (purpose === 'resetPassword' || purpose === 'resendVerification') {
checklist = [usr];
}
@ -2242,7 +2242,7 @@ DialogBoxMorph.prototype.promptCredentials = function (
this.edit = function () {
if (purpose === 'changePassword') {
opw.edit();
} else { // 'signup', 'login', 'resetPassword'
} else { // 'signup', 'login', 'resetPassword', 'resendVerification'
usr.edit();
}
};