Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Sup 2361 social no password #522

Merged
merged 3 commits into from
Nov 4, 2015
Merged
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
23 changes: 13 additions & 10 deletions app/settings/account-info/account-info.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@

angular.module('tc.settings').controller('AccountInfoController', AccountInfoController);

AccountInfoController.$inject = ['userData', 'UserService', 'ProfileService', '$log', 'ISO3166', 'toaster', '$scope', '$timeout'];
AccountInfoController.$inject = ['userData', 'UserService', 'ProfileService', '$log', 'ISO3166', 'toaster', '$scope', '$timeout', '$state'];

function AccountInfoController(userData, UserService, ProfileService, $log, ISO3166, toaster, $scope, $timeout) {
function AccountInfoController(userData, UserService, ProfileService, $log, ISO3166, toaster, $scope, $timeout, $state) {
var vm = this;
vm.saveAccountInfo = saveAccountInfo;
vm.updateCountry = updateCountry;
vm.submitNewPassword = submitNewPassword;
vm.isSocialRegistrant = false;
vm.formProcessing = {
accountInfoForm: false,
newPasswordForm: false
};
var originalUserData = userData;
vm.saveAccountInfo = saveAccountInfo;
vm.updateCountry = updateCountry;
vm.submitNewPassword = submitNewPassword;

activate();

function activate() {
vm.isSocialRegistrant = false;

vm.formProcessing = {
accountInfoForm: false,
newPasswordForm: false
};

vm.userData = userData.clone();
processData(vm.userData);

UserService.getUserProfile({fields: 'credential'})
.then(function(res) {
vm.isSocialRegistrant = !res.credential.hasPassword;
Expand Down
76 changes: 37 additions & 39 deletions app/settings/account-info/account-info.jade
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@
.form-label Email
input.form-field.grey(name="email", value="{{vm.userData.email}}", disabled=true)

div(ng-hide="vm.isSocialRegistration")
div(ng-hide="vm.isSocialRegistrant")
form(name="vm.newPasswordForm", role="form", ng-submit="vm.newPasswordForm.$valid && vm.submitNewPassword()", novalidate)
.form-label Current password

.validation-bar(ng-class="{ 'error-bar': (vm.newPasswordForm.currentPassword.$dirty && vm.newPasswordForm.currentPassword.$invalid) }")
toggle-password.tc-input.password(
ng-model="vm.currentPassword"
)
toggle-password.tc-input.password(ng-model="vm.currentPassword")

.form-input-error(ng-show="vm.newPasswordForm.currentPassword.$dirty && vm.newPasswordForm.currentPassword.$invalid")
p(ng-show="vm.newPasswordForm.currentPassword.$error.required") This is a required field.

p(ng-show="vm.newPasswordForm.currentPassword.$error.incorrect") Your current password is incorrect. Please check that you entered the right one.

.form-label New Password

.validation-bar
toggle-password-with-tips.tc-input.password(
placeholder="Pick a new password"
)
toggle-password-with-tips.tc-input.password(placeholder="Pick a new password")

.tips.password-tips(ng-show="vm.passwordFocus")
.arrow

h3 Password Tips:

p Your password must have:
Expand All @@ -46,49 +45,48 @@
button.tc-btn.save(type="submit", tc-busy-button, tc-busy-when="vm.formProcessing.newPasswordForm", ng-disabled="vm.newPasswordForm.$invalid || vm.newPasswordForm.$pristine", ng-class="{'disabled': vm.newPasswordForm.$invalid || vm.newPasswordForm.$pristine}") Change Password


div(ng-show="vm.isSocialRegistration")
div(ng-show="vm.isSocialRegistrant")
p You joined Topcoder by using an external account, so we don't have a password for you.


form(name="vm.accountInfoForm", role="form", novalidate, autocomplete="off")

.settings-section.name
.section-info
h2 Name

.description Required for legal purposes; will be kept private and not shared with anyone.

.section-fields
// Stops Chrome from autofilling and autocompleting (along with autocomplete="off" on the form)
input(autocomplete="false", name="hidden", type="text", style="display:none;")

// Stops Chrome from autofilling and autocompleting (along with autocomplete="off" on the form)
input(autocomplete="false", name="hidden", type="text", style="display:none;")
.form-label.first First name
span(style="text-transform: none;")  (Given name)
span.mandatory *mandatory
.validation-bar(ng-class="{ 'error-bar': (vm.accountInfoForm.$dirty && vm.accountInfoForm.firstname.$invalid), 'success-bar': (vm.accountInfoForm.$dirty && vm.accountInfoForm.firstname.$valid)}")
input.tc-input(
name="firstname", type="text",
placeholder="First",
ng-model="vm.userData.firstName",
maxlength="64", required,
ng-class="{'form-field-focused': hasFocus==true}"
)
.form-input-error(ng-show="vm.accountInfoForm.firstname.$invalid")
p(ng-show="vm.accountInfoForm.firstname.$error.required") This is a required field.

.form-label Last name
span(style="text-transform: none;")  (Surname)
span.mandatory *mandatory
.validation-bar(ng-class="{ 'error-bar': (vm.accountInfoForm.$dirty && vm.accountInfoForm.lastname.$invalid), 'success-bar': (vm.accountInfoForm.$dirty && vm.accountInfoForm.lastname.$valid)}")
input.tc-input(
name="lastname", type="text",
placeholder="Last",
ng-model="vm.userData.lastName",
maxlength="64", required,
ng-class="{'form-field-focused': hasFocus==true}"
)
.form-input-error(ng-show="vm.accountInfoForm.lastname.$invalid")
p(ng-show="vm.accountInfoForm.lastname.$error.required") This is a required field.
.form-label.first First name
span(style="text-transform: none;")  (Given name)

span.mandatory *mandatory
.validation-bar(ng-class="{ 'error-bar': (vm.accountInfoForm.$dirty && vm.accountInfoForm.firstname.$invalid), 'success-bar': (vm.accountInfoForm.$dirty && vm.accountInfoForm.firstname.$valid)}")
input.tc-input(
name="firstname", type="text",
placeholder="First",
ng-model="vm.userData.firstName",
maxlength="64", required,
ng-class="{'form-field-focused': hasFocus==true}"
)
.form-input-error(ng-show="vm.accountInfoForm.firstname.$invalid")
p(ng-show="vm.accountInfoForm.firstname.$error.required") This is a required field.

.form-label Last name
span(style="text-transform: none;")  (Surname)
span.mandatory *mandatory
.validation-bar(ng-class="{ 'error-bar': (vm.accountInfoForm.$dirty && vm.accountInfoForm.lastname.$invalid), 'success-bar': (vm.accountInfoForm.$dirty && vm.accountInfoForm.lastname.$valid)}")
input.tc-input(
name="lastname", type="text",
placeholder="Last",
ng-model="vm.userData.lastName",
maxlength="64", required,
ng-class="{'form-field-focused': hasFocus==true}"
)
.form-input-error(ng-show="vm.accountInfoForm.lastname.$invalid")
p(ng-show="vm.accountInfoForm.lastname.$error.required") This is a required field.

.settings-section.address
.section-info
Expand Down
90 changes: 66 additions & 24 deletions app/settings/account-info/account-info.spec.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,97 @@
/* jshint -W117, -W030 */
describe('Account Info Controller', function() {
var controller;
var vm;
var credential = {hasPassword: true};
var deferred;
var fakeStateGo;

beforeEach(function() {
bard.appModule('tc.settings');
bard.inject(this, '$controller', '$rootScope', '$q');

deferred = $q.defer();

var userService = {
getUserIdentity: function() {
return {handle: 'nicktest', email: '[email protected]'};
},
resetPassword: function() {
return $q.when({});
},
getUserProfile: function() {
return deferred.promise;
}
};

var userData = {
handle: 'nicktest',
email: '[email protected]',
homeCountryCode: 'USA'
homeCountryCode: 'USA',
clone: function() {
return angular.copy(this);
}
};

var state = {
go: function(transitionTo) {
return transitionTo;
}
}

fakeStateGo = sinon.spy(state, 'go');

controller = $controller('AccountInfoController', {
UserService: userService,
userData: userData
userData: userData,
$scope: $rootScope.$new(),
$state: state
});

vm = controller;
});

bard.verifyNoOutstandingHttpRequests();

// TODO: re-add tests!
// it('should be created successfully', function() {
// expect(controller).to.exist;
// });
//
// describe('updating a user\'s password', function() {
// beforeEach(function() {
// $rootScope.$apply();
// });
//
// xit('should update a user\'s password if the current password was entered correctly', function() {
// controller.submitNewPassword();
// });
//
// xit('should return an error if the user entered an incorrect current password', function() {
//
// });
//
// xit('should return an error if there was a server error', function() {
//
// });
// });
it('should be created successfully', function() {
expect(controller).to.exist;
});

describe('updating a user\'s password', function() {
// beforeEach(function() {
// $rootScope.$apply();
// });

xit('should return an error if the user entered an incorrect current password', function() {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests for this case please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh, you saw that

});
});

describe('vm.isSocialRegistrant', function() {
it('should be false if a user has a password', function() {
deferred.resolve({credential: credential});

$rootScope.$apply();

expect(vm.isSocialRegistrant).to.be.false;
});

it('should be true if a user does not have a password', function() {
credential.hasPassword = false;

deferred.resolve({credential: credential});

$rootScope.$apply();

expect(vm.isSocialRegistrant).to.be.true;
});

it('should go to the edit page on error', function() {
deferred.reject();

$rootScope.$apply();

expect(fakeStateGo).to.have.been.calledWith('settings.profile');
});
});
});
22 changes: 21 additions & 1 deletion app/specs.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="../bower_components/restangular/dist/restangular.js"></script>
<script src="../bower_components/angular-touch/angular-touch.js"></script>
<script src="../bower_components/angular-carousel/dist/angular-carousel.js"></script>
<script src="../bower_components/matchmedia/matchMedia.js"></script>
<script src="../bower_components/ngSticky/lib/sticky.js"></script>
<script src="../bower_components/angular-mocks/angular-mocks.js"></script>
<script src="../bower_components/sinon/index.js"></script>
<script src="../bower_components/bardjs/dist/bard.js"></script>
Expand All @@ -95,6 +97,8 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/skill-picker/skill-picker.module.js"></script>
<script src="/app/skill-picker/skill-picker.routes.js"></script>
<script src="/app/skill-picker/skill-picker.controller.js"></script>
<script src="/app/sitemap/sitemap.module.js"></script>
<script src="/app/sitemap/sitemap.routes.js"></script>
<script src="/app/settings/settings.module.js"></script>
<script src="/app/settings/settings.routes.js"></script>
<script src="/app/settings/settings.controller.js"></script>
Expand All @@ -106,17 +110,21 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/services/user.service.js"></script>
<script src="/app/services/tcAuth.service.js"></script>
<script src="/app/services/tags.service.js"></script>
<script src="/app/services/statistics.service.js"></script>
<script src="/app/services/srm.service.js"></script>
<script src="/app/services/scorecard.service.js"></script>
<script src="/app/services/review.service.js"></script>
<script src="/app/services/profile.service.js"></script>
<script src="/app/services/notification.service.js"></script>
<script src="/app/services/nav.service.js"></script>
<script src="/app/services/memberCert.service.js"></script>
<script src="/app/services/jwtInterceptor.service.js"></script>
<script src="/app/services/introduction.service.js"></script>
<script src="/app/services/image.service.js"></script>
<script src="/app/services/helpers.service.js"></script>
<script src="/app/services/externalAccounts.service.js"></script>
<script src="/app/services/emptyState.service.js"></script>
<script src="/app/services/communityData.service.js"></script>
<script src="/app/services/challenge.service.js"></script>
<script src="/app/services/blog.service.js"></script>
<script src="/app/services/authtoken.service.js"></script>
Expand Down Expand Up @@ -155,6 +163,7 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/layout/layout.module.js"></script>
<script src="/app/layout/header/header.controller.js"></script>
<script src="/app/filters/underscore-strip.filter.js"></script>
<script src="/app/filters/truncate.filter.js"></script>
<script src="/app/filters/track.filter.js"></script>
<script src="/app/filters/time-diff.filter.js"></script>
<script src="/app/filters/role.filter.js"></script>
Expand All @@ -173,6 +182,8 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/directives/tcui-components.module.js"></script>
<script src="/app/directives/track-toggle/track-toggle.directive.js"></script>
<script src="/app/directives/tc-transclude.directive.js"></script>
<script src="/app/directives/tc-tabs/tc-tabs.directive.js"></script>
<script src="/app/directives/tc-sticky/tc-sticky.directive.js"></script>
<script src="/app/directives/tc-section/tc-section.directive.js"></script>
<script src="/app/directives/tc-paginator/tc-paginator.directive.js"></script>
<script src="/app/directives/tc-endless-paginator/tc-endless-paginator.directive.js"></script>
Expand All @@ -181,22 +192,29 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/directives/skill-tile/skill-tile.directive.js"></script>
<script src="/app/directives/responsive-carousel/responsive-carousel.directive.js"></script>
<script src="/app/directives/profile-widget/profile-widget.directive.js"></script>
<script src="/app/directives/page-state-header/page-state-header.directive.js"></script>
<script src="/app/directives/on-file-change.directive.js"></script>
<script src="/app/directives/ios-card/ios-card.directive.js"></script>
<script src="/app/directives/input-sticky-placeholder/input-sticky-placeholder.directive.js"></script>
<script src="/app/directives/history-graph/history-graph.directive.js"></script>
<script src="/app/directives/header/header-menu-item.directive.js"></script>
<script src="/app/directives/focus-on.directive.js"></script>
<script src="/app/directives/external-account/external-account.directive.js"></script>
<script src="/app/directives/empty-state-placeholder/empty-state-placeholder.directive.js"></script>
<script src="/app/directives/distribution-graph/distribution-graph.directive.js"></script>
<script src="/app/directives/challenge-user-place/challenge-user-place.directive.js"></script>
<script src="/app/directives/challenge-tile/challenge-tile.directive.js"></script>
<script src="/app/directives/challenge-links/challenge-links.directive.js"></script>
<script src="/app/directives/busy-button/busy-button.directive.js"></script>
<script src="/app/directives/badges/badge-tooltip.directive.js"></script>
<script src="/app/directives/account/validate-register.directive.js"></script>
<script src="/app/directives/account/validate-email.directive.js"></script>
<script src="/app/directives/account/toggle-password-with-tips/toggle-password-with-tips.directive.js"></script>
<script src="/app/directives/account/toggle-password/toggle-password.directive.js"></script>
<script src="/app/community/community.module.js"></script>
<script src="/app/community/statistics.controller.js"></script>
<script src="/app/community/members.controller.js"></script>
<script src="/app/community/community.routes.js"></script>
<script src="/app/blocks/logger/logger.module.js"></script>
<script src="/app/blocks/logger/logger.js"></script>
<script src="/app/blocks/logger/logEnhancer.js"></script>
Expand All @@ -221,6 +239,7 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/my-dashboard/my-dashboard.spec.js"></script>
<script src="/app/my-srms/my-srms.spec.js"></script>
<script src="/app/profile/profile.controller.spec.js"></script>
<script src="/app/settings/settings.spec.js"></script>
<script src="/app/services/authToken.service.spec.js"></script>
<script src="/app/services/challenge.service.spec.js"></script>
<script src="/app/services/helpers.service.spec.js"></script>
Expand All @@ -229,7 +248,6 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/services/tcAuth.service.spec.js"></script>
<script src="/app/services/user.service.spec.js"></script>
<script src="/app/services/userStats.service.spec.js"></script>
<script src="/app/settings/settings.spec.js"></script>
<script src="/app/skill-picker/skill-picker.spec.js"></script>
<script src="/app/account/login/login.spec.js"></script>
<script src="/app/account/register/register.spec.js"></script>
Expand All @@ -238,9 +256,11 @@ <h1><a href="specs.html">Spec Runner</a></h1>
<script src="/app/directives/badges/badge-tooltip.spec.js"></script>
<script src="/app/directives/busy-button/busy-button.directive.spec.js"></script>
<script src="/app/directives/challenge-tile/challenge-tile.spec.js"></script>
<script src="/app/directives/empty-state-placeholder/empty-state-placeholder.spec.js"></script>
<script src="/app/directives/external-account/external-account.directive.spec.js"></script>
<script src="/app/directives/tc-endless-paginator/tc-endless-paginator.spec.js"></script>
<script src="/app/directives/tc-paginator/tc-paginator.spec.js"></script>
<script src="/app/directives/tc-tabs/tc-tabs.directive.spec.js"></script>
<script src="/app/my-dashboard/community-updates/community-updates.spec.js"></script>
<script src="/app/my-dashboard/header-dashboard/header-dashboard.spec.js"></script>
<script src="/app/my-dashboard/my-challenges/my-challenges.spec.js"></script>
Expand Down
1 change: 0 additions & 1 deletion assets/css/directives/toggle-password.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ toggle-password {
align-items: center;
justify-content: space-between;


input#current-password-input {
width: 155px;
margin-bottom: 0;
Expand Down
Loading