Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(account): email address must be confirmed #467

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@
data: {
requiresLogin: true,
},
resolve: {
emailConfirmed: function (AccountService) {
return AccountService.getUserDetails().then(function (data) {
return data.data.me.emailIsConfirmed;
});
}
}
})
.state('account.dataupload', {
url: '/:id/dataupload',
Expand Down Expand Up @@ -366,6 +373,11 @@
templateUrl: 'views/account.dashboard.html',
},
},
onEnter: function ($state, emailConfirmed) {
if (!emailConfirmed) {
$state.go('account.settings');
}
}
})
.state('account.settings', {
url: '/settings',
Expand Down Expand Up @@ -422,6 +434,11 @@
templateUrl: 'views/account.box.register.html',
},
},
onEnter: function ($state, emailConfirmed) {
if (!emailConfirmed) {
$state.go('account.settings');
}
}
})
.state('register', {
url: '/register',
Expand Down
10 changes: 10 additions & 0 deletions app/scripts/controllers/account.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
vm.updateDisabled = updateDisabled;
vm.changeAttribute = changeAttribute;
vm.deleteAccount = deleteAccount;
vm.resendEmailConfirmation = resendEmailConfirmation;

activate();

Expand All @@ -42,6 +43,15 @@
});
}

function resendEmailConfirmation () {
vm.alerts.pop();

return AccountService.resendEmailConfirmation()
.then(function (data) {
vm.alerts.push({ type: 'info', msg: data.message });
});
}

function updateAccount () {
vm.alerts.pop();
if (angular.isDefined(vm.currentPassword)) {
Expand Down
13 changes: 12 additions & 1 deletion app/scripts/services/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
transferDevice: transferDevice,
revokeToken: revokeToken,
getTransferToken: getTransferToken,
claimDevice: claimDevice
claimDevice: claimDevice,
resendEmailConfirmation: resendEmailConfirmation
};

return service;
Expand Down Expand Up @@ -296,5 +297,15 @@
})
.catch(failed);
}

function resendEmailConfirmation (data) {
return $http.post(app.API_URL + '/users/me/resend-email-confirmation', data, {
auth: true
})
.then(function (response) {
return response.data;
})
.catch(failed);
}
}
})();
1 change: 1 addition & 0 deletions app/views/account.settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h1><i class="fa fa-user-circle-o 2x"></i> {{'ACCOUNT_TITLE'|translate}}</h1>
<div class="form-group">
<span class="badge sborange" ng-hide="settings.details.emailIsConfirmed">{{'ACCOUNT_MAIL_NOT_CONFIRMED'|translate}}</span>
<span class="badge sbgreen" ng-show="settings.details.emailIsConfirmed">{{'ACCOUNT_MAIL_CONFIRMED'|translate}}</span>
<button type="button" class="btn btn-default pull-right" ng-click="settings.resendEmailConfirmation()">{{'ACCOUNT_RESEND_EMAIL'|translate}}</button>
</div>
<hr>
<div class="form-group">
Expand Down