PrincipalsTestUtil.assertResendEmailTokenSucceeds(camAdminRestContext, user.id, function(newToken) { // Global administrators can resend a token PrincipalsTestUtil.assertResendEmailTokenSucceeds(globalAdminRestContext, user.id, function(newToken) { return callback(); }); });
PrincipalsTestUtil.assertResendEmailTokenFails(gtAdminRestContext, user.id, 401, function() { // Tenant administrators from the same tenant as the user can resend a token PrincipalsTestUtil.assertResendEmailTokenSucceeds(camAdminRestContext, user.id, function(newToken) { // Global administrators can resend a token PrincipalsTestUtil.assertResendEmailTokenSucceeds(globalAdminRestContext, user.id, function(newToken) { return callback(); }); }); });
RestAPI.Authentication.login(restContext, params.username, 'password', function(err) { assert.ok(!err); // Verify we can resend the email verification token PrincipalsTestUtil.assertResendEmailTokenSucceeds(restContext, user.id, function(newToken) { // Assert we've sent the same token assert.strictEqual(newToken, token); // Sanity-check we can use this new token to verify the email address PrincipalsTestUtil.assertVerifyEmailSucceeds(restContext, user.id, newToken, function() { return callback(); }); }); });
PrincipalsTestUtil.assertUpdateUserSucceeds(simong.restContext, simong.user.id, {'email': email}, function(user, token) { // Resending a token now should be OK PrincipalsTestUtil.assertResendEmailTokenSucceeds(simong.restContext, simong.user.id, function(newToken) { // Use the token to verify the new email address PrincipalsTestUtil.assertVerifyEmailSucceeds(simong.restContext, simong.user.id, newToken, function() { // Resending a token should now fail as the token has been used and should be removed PrincipalsTestUtil.assertResendEmailTokenFails(simong.restContext, simong.user.id, 404, function() { return callback(); }); }); }); });