diff --git a/public/js/main.js b/public/js/main.js index 32785360c7..3f81c3c571 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -24,7 +24,6 @@ $(document).ready(function() { l = location.pathname.split('/'); cn = l[l.length - 1]; - console.log(cn); $.ajax({ type: 'POST', data: {challengeNumber: cn}, @@ -48,7 +47,8 @@ profileValidation.controller('profileValidationController', ['$scope', '$http', $http.get('/account/api').success(function(data) { $scope.user = data.user; $scope.user.profile.username = $scope.user.profile.username.toLowerCase(); - $scope.storedUsername = $scope.user.profile.username; + $scope.storedUsername = data.user.profile.username; + $scope.storedEmail = data.user.email; $scope.user.email = $scope.user.email.toLowerCase(); $scope.user.profile.twitterHandle = $scope.user.profile.twitterHandle.toLowerCase(); }); @@ -76,14 +76,16 @@ profileValidation.directive('uniqueUsername', function($http) { ngModel.$setValidity('unique', true); if (element.val()) { $http.get("/api/checkUniqueUsername/" + element.val()).success(function (data) { - if (data) { + if (element.val() == scope.storedUsername) { + ngModel.$setValidity('unique', true); + } else if (data) { ngModel.$setValidity('unique', false); } }); } }); } - }; + } }); profileValidation.directive('uniqueEmail', function($http) { @@ -95,12 +97,14 @@ profileValidation.directive('uniqueEmail', function($http) { ngModel.$setValidity('unique', true); if (element.val()) { $http.get("/api/checkUniqueEmail/" + encodeURIComponent(element.val())).success(function (data) { - if (data) { + if (element.val() == scope.storedEmail) { + ngModel.$setValidity('unique', true); + } else if (data) { ngModel.$setValidity('unique', false); } }); - } + }; }); } - }; + } }); \ No newline at end of file diff --git a/views/account/profile.jade b/views/account/profile.jade index 41c7102c36..bf1bf83974 100644 --- a/views/account/profile.jade +++ b/views/account/profile.jade @@ -13,7 +13,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='name') Name * .col-sm-4 - input.form-control(type='text', placeholder='Name', name='name', ng-model='user.profile.name', ng-minlength='3', ng-maxlength='50', required='required', id='name') + input.form-control(type='text', placeholder='Name', name='name', autocomplete="off", ng-model='user.profile.name', ng-minlength='3', ng-maxlength='50', required='required', id='name') .col-sm-4.col-sm-offset-5(ng-show="profileForm.name.$invalid && !profileForm.name.$pristine && profileForm.name.$error.required") alert(type='danger') span.ion-close-circled @@ -30,7 +30,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (path to public profile) * .col-sm-4 - input.form-control(type='text', placeholder='username' name='username', id='username', ng-model='user.profile.username', required='required', ng-minlength='5', ng-maxlength='20', ng-keypress='', unique-username='') + input.form-control(type='text', placeholder='username' name='username', autocomplete="off", id='username', ng-model='user.profile.username', required='required', ng-minlength='5', ng-maxlength='20', ng-keypress='', unique-username='') .col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.required && !profileForm.username.$pristine") alert(type='danger') span.ion-close-circled @@ -43,15 +43,15 @@ block content alert(type='danger') span.ion-close-circled | Your username must be fewer than 15 characters. - .col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.unique && !profileForm.username.$pristine") + .col-sm-4.col-sm-offset-5(ng-show="profileForm.username.$error.unique && !profileForm.username.$pristine && $scope.storedUsername !== user.profile.username") alert(type='danger') span.ion-close-circled - | This username is taken. + | That username is taken. .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') Email * .col-sm-4 - input.form-control(type='email', name='email', id='email', ng-model='user.email', required='required') + input.form-control(type='email', name='email', id='email', autocomplete="off", ng-model='user.email', required='required', ng-keypress='', unique-email='') .col-sm-4.col-sm-offset-5(ng-show="profileForm.email.$error.required && !profileForm.email.$pristine") alert(type='danger') span.ion-close-circled @@ -60,11 +60,15 @@ block content alert(type='danger') span.ion-close-circled | Please enter a valid email format. + .col-sm-4.col-sm-offset-5(ng-show="profileForm.email.$error.unique && !profileForm.email.$pristine") + alert(type='danger') + span.ion-close-circled + | That email is taken. .form-group label.col-sm-3.col-sm-offset-2.control-label(for='location') Location .col-sm-4 - input.form-control(type='text', name='location', id='location', ng-model='user.profile.location') + input.form-control(type='text', name='location', autocomplete="off", id='location', ng-model='user.profile.location') .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') Link to Profile Photo (1:1 ratio) @@ -78,7 +82,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='bio') Bio (140 characters) .col-sm-4 - input.form-control(type='text', name='bio', ng-model='user.profile.bio', ng-maxlength='140', id='bio') + input.form-control(type='text', name='bio', autocomplete="off", ng-model='user.profile.bio', ng-maxlength='140', id='bio') .col-sm-4.col-sm-offset-5(ng-show='profileForm.bio.$error.maxlength && !profileForm.bio.$pristine') alert(type='danger') span.ion-close-circled @@ -98,7 +102,7 @@ block content .col-sm-4 .input-group.twitter-input span.input-group-addon @ - input.form-control(type='text', name='twitterHandle', id='twitterHandle', ng-model='user.profile.twitterHandle', ng-maxlength='15', ng-pattern="/^[A-z0-9_]+$/") + input.form-control(type='text', name='twitterHandle', autocomplete="off", id='twitterHandle', ng-model='user.profile.twitterHandle', ng-maxlength='15', ng-pattern="/^[A-z0-9_]+$/") .col-sm-4.col-sm-offset-5(ng-show="profileForm.twitterHandle.$error.pattern") alert(type='danger') span.ion-close-circled @@ -110,7 +114,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') Github .col-sm-4 - input.form-control(type='url', name='githubProfile', id='githubProfile', ng-model='user.profile.githubProfile', placeholder='http://') + input.form-control(type='url', name='githubProfile', id='githubProfile', autocomplete="off", ng-model='user.profile.githubProfile', placeholder='http://') .col-sm-4.col-sm-offset-5(ng-show="profileForm.githubProfile.$error.url && !profileForm.githubProfile.$pristine") alert(type='danger') span.ion-close-circled @@ -119,7 +123,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') CodePen .col-sm-4 - input.form-control(type='url', name='codepenProfile', id='codepenProfile', ng-model='user.profile.codepenProfile', placeholder='http://') + input.form-control(type='url', name='codepenProfile', id='codepenProfile', autocomplete="off", ng-model='user.profile.codepenProfile', placeholder='http://') .col-sm-4.col-sm-offset-5(ng-show="profileForm.codepenProfile.$error.url && !profileForm.codepenProfile.$pristine") alert(type='danger') span.ion-close-circled @@ -128,7 +132,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') CoderByte .col-sm-4 - input.form-control(type='url', name='coderbyteProfile', id='coderbyteProfile', ng-model='user.profile.coderbyteProfile', placeholder='http://') + input.form-control(type='url', name='coderbyteProfile', id='coderbyteProfile', autocomplete="off", ng-model='user.profile.coderbyteProfile', placeholder='http://') .col-sm-4.col-sm-offset-5(ng-show="profileForm.coderbyteProfile.$error.url && !profileForm.coderbyteProfile.$pristine") alert(type='danger') span.ion-close-circled @@ -137,7 +141,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') LinkedIn .col-sm-4 - input.form-control(type='url', name='linkedinProfile', id='linkedinProfile', ng-model='user.profile.linkedinProfile', placeholder='http://') + input.form-control(type='url', name='linkedinProfile', id='linkedinProfile', autocomplete="off", ng-model='user.profile.linkedinProfile', placeholder='http://') .col-sm-4.col-sm-offset-5(ng-show="profileForm.linkedinProfile.$error.url && !profileForm.linkedinProfile.$pristine") alert(type='danger') span.ion-close-circled @@ -158,7 +162,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website1Title') Title .col-sm-4 - input.form-control(type='text', name='website1Title', id='website1Title', ng-model='user.portfolio.website1Title', ng-maxlength='140') + input.form-control(type='text', name='website1Title', id='website1Title', autocomplete="off", ng-model='user.portfolio.website1Title', ng-maxlength='140') .col-sm-4.col-sm-offset-5(ng-show="profileForm.website1Title.$error.maxlength && !profileForm.website1Title.$pristine") alert(type='danger') span.ion-close-circled @@ -167,12 +171,12 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website1Link') Link .col-sm-4 - input.form-control(type='text', name='website1Link', id='website1Link', ng-model='user.portfolio.website1Link', placeholder='http://') + input.form-control(type='text', name='website1Link', id='website1Link', autocomplete="off", ng-model='user.portfolio.website1Link', placeholder='http://') .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website1Image') Image Link (4:3 ratio) .col-sm-4 - input.form-control(type='text', name='website1Image', id='website1Image', ng-model='user.portfolio.website1Image', placeholder='http://') + input.form-control(type='text', name='website1Image', id='website1Image', autocomplete="off", ng-model='user.portfolio.website1Image', placeholder='http://') .col-sm-4.col-sm-offset-5.flat-top h3 Second Portfolio Project @@ -180,7 +184,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website2Title') Title .col-sm-4 - input.form-control(type='text', name='website2Title', id='website2Title', ng-model='user.portfolio.website2Title', ng-maxlength='140') + input.form-control(type='text', name='website2Title', id='website2Title', autocomplete="off", ng-model='user.portfolio.website2Title', ng-maxlength='140') .col-sm-4.col-sm-offset-5(ng-show="profileForm.website2Title.$error.maxlength && !profileForm.website2Title.$pristine") alert(type='danger') span.ion-close-circled @@ -189,12 +193,12 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website2Link') Link .col-sm-4 - input.form-control(type='text', name='website2Link', id='website2Link', ng-model='user.portfolio.website2Link', placeholder='http://') + input.form-control(type='text', name='website2Link', id='website2Link', autocomplete="off", ng-model='user.portfolio.website2Link', placeholder='http://') .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website2Image') Image Link (4:3 ratio) .col-sm-4 - input.form-control(type='text', name='website2Image', id='website2Image', ng-model='user.portfolio.website2Image', placeholder='http://') + input.form-control(type='text', name='website2Image', id='website2Image', autocomplete="off", ng-model='user.portfolio.website2Image', placeholder='http://') .col-sm-4.col-sm-offset-5.flat-top h3 Third Portfolio Project @@ -202,7 +206,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website3Title') Title .col-sm-4 - input.form-control(type='text', name='website3Title', id='website3Title', ng-model='user.portfolio.website3Title', ng-maxlength='140') + input.form-control(type='text', name='website3Title', id='website3Title', autocomplete="off", ng-model='user.portfolio.website3Title', ng-maxlength='140') .col-sm-4.col-sm-offset-5(ng-show="profileForm.website3Title.$error.maxlength && !profileForm.website3Title.$pristine") alert(type='danger') span.ion-close-circled @@ -211,12 +215,12 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website3Link') Link .col-sm-4 - input.form-control(type='text', name='website3Link', id='website3Link', ng-model='user.portfolio.website3Link', placeholder='http://') + input.form-control(type='text', name='website3Link', id='website3Link', autocomplete="off", ng-model='user.portfolio.website3Link', placeholder='http://') .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website3Image') Image Link (4:3 ratio) .col-sm-4 - input.form-control(type='text', name='website3Image', id='website3Image', ng-model='user.portfolio.website3Image', placeholder='http://') + input.form-control(type='text', name='website3Image', id='website3Image', autocomplete="off", ng-model='user.portfolio.website3Image', placeholder='http://') .form-group .col-sm-offset-5.col-sm-4 @@ -233,7 +237,7 @@ block content a.btn.btn-lg.btn-block.btn-primary.btn-link-social(href='/') Take me to my current challenge a.btn.btn-lg.btn-block.btn-warning.btn-link-social(href='/logout') Sign out br - - if (!user.google || !user.facebook || !user.github || !user.linkedin || !user.twitter) + - if (!user.google || !user.facebook || /*!user.github ||*/ !user.linkedin || !user.twitter) .panel.panel-primary .panel-heading.text-center Link other services to your account: .panel-body