From 387a8b8ae37f66a06b6e8b8aa3f47051bcb5393e Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 24 Feb 2015 13:39:30 +0000 Subject: [PATCH] hide some forms in user settings if authentication is managed by external system --- .../infrastructure/ExpressLocals.coffee | 5 + services/web/app/views/user/settings.jade | 155 +++++++++--------- 2 files changed, 84 insertions(+), 76 deletions(-) diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index 856dcd51a7..8a64cce94b 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -112,6 +112,11 @@ module.exports = (app)-> res.locals.formatPrice = SubscriptionFormatters.formatPrice next() + app.use (req, res, next)-> + res.locals.externalAuthenticationSystemUsed = -> + Settings.ldap? + next() + app.use (req, res, next)-> if req.session.user? res.locals.user = diff --git a/services/web/app/views/user/settings.jade b/services/web/app/views/user/settings.jade index d4a213aefb..3969a2c1d0 100644 --- a/services/web/app/views/user/settings.jade +++ b/services/web/app/views/user/settings.jade @@ -19,19 +19,20 @@ block content h3 #{translate("update_account_info")} form(async-form="settings", name="settingsForm", method="POST", action="/user/settings", novalidate) input(type="hidden", name="_csrf", value=csrfToken) - .form-group - label(for='email') #{translate("email")} - input.form-control( - type='email', - name='email', - placeholder="email@example.com" - required, - ng-model="email", - ng-init="email = #{JSON.stringify(user.email)}", - ng-model-options="{ updateOn: 'blur' }" - ) - span.small.text-primary(ng-show="settingsForm.email.$invalid && settingsForm.email.$dirty") - | #{translate("must_be_email_address")} + if !externalAuthenticationSystemUsed() + .form-group + label(for='email') #{translate("email")} + input.form-control( + type='email', + name='email', + placeholder="email@example.com" + required, + ng-model="email", + ng-init="email = #{JSON.stringify(user.email)}", + ng-model-options="{ updateOn: 'blur' }" + ) + span.small.text-primary(ng-show="settingsForm.email.$invalid && settingsForm.email.$dirty") + | #{translate("must_be_email_address")} .form-group label(for='firstName').control-label #{translate("first_name")} input.form-control( @@ -51,75 +52,77 @@ block content type='submit', ng-disabled="settingsForm.$invalid" ) #{translate("update")} - - .col-md-5.col-md-offset-1 - h3 #{translate("change_password")} - form(async-form="changepassword", name="changePasswordForm", action="/user/password/update", method="POST", novalidate) - input(type="hidden", name="_csrf", value=csrfToken) - .form-group - label(for='currentPassword') #{translate("current_password")} - input.form-control( - type='password', - name='currentPassword', - placeholder='*********', - ng-model="currentPassword", - required - ) - span.small.text-primary(ng-show="changePasswordForm.currentPassword.$invalid && changePasswordForm.currentPassword.$dirty") - | #{translate("required")} - .form-group - label(for='newPassword1') #{translate("new_password")} - input.form-control( - id='newPassword1', - type='password', - name='newPassword1', - placeholder='*********', - ng-model="newPassword1", - required - ) - span.small.text-primary(ng-show="changePasswordForm.newPassword1.$invalid && changePasswordForm.newPassword1.$dirty") - | #{translate("required")} - .form-group - label(for='newPassword2') #{translate("confirm_new_password")} - input.form-control( - type='password', - name='newPassword2', - placeholder='*********', - ng-model="newPassword2", - equals="newPassword1" - ) - span.small.text-primary(ng-show="changePasswordForm.newPassword2.$invalid && changePasswordForm.newPassword2.$dirty") - | #{translate("doesnt_match")} - .actions - button.btn.btn-primary( - type='submit', - ng-disabled="changePasswordForm.$invalid" - ) #{translate("change")} + if !externalAuthenticationSystemUsed() + .col-md-5.col-md-offset-1 + h3 #{translate("change_password")} + form(async-form="changepassword", name="changePasswordForm", action="/user/password/update", method="POST", novalidate) + input(type="hidden", name="_csrf", value=csrfToken) + .form-group + label(for='currentPassword') #{translate("current_password")} + input.form-control( + type='password', + name='currentPassword', + placeholder='*********', + ng-model="currentPassword", + required + ) + span.small.text-primary(ng-show="changePasswordForm.currentPassword.$invalid && changePasswordForm.currentPassword.$dirty") + | #{translate("required")} + .form-group + label(for='newPassword1') #{translate("new_password")} + input.form-control( + id='newPassword1', + type='password', + name='newPassword1', + placeholder='*********', + ng-model="newPassword1", + required + ) + span.small.text-primary(ng-show="changePasswordForm.newPassword1.$invalid && changePasswordForm.newPassword1.$dirty") + | #{translate("required")} + .form-group + label(for='newPassword2') #{translate("confirm_new_password")} + input.form-control( + type='password', + name='newPassword2', + placeholder='*********', + ng-model="newPassword2", + equals="newPassword1" + ) + span.small.text-primary(ng-show="changePasswordForm.newPassword2.$invalid && changePasswordForm.newPassword2.$dirty") + | #{translate("doesnt_match")} + .actions + button.btn.btn-primary( + type='submit', + ng-disabled="changePasswordForm.$invalid" + ) #{translate("change")} | !{moduleIncludes("userSettings", locals)} hr - p.small - | #{translate("newsletter_info_and_unsubscribe")} - a( - href, - ng-click="unsubscribe()", - ng-show="subscribed && !unsubscribing" - ) #{translate("unsubscribe")} - span( - ng-show="unsubscribing" - ) - i.fa.fa-spin.fa-refresh - | #{translate("unsubscribing")} - span.text-success( - ng-show="!subscribed" - ) - i.fa.fa-check - | #{translate("unsubscribed")} + if !externalAuthenticationSystemUsed() - p #{translate("need_to_leave")} - a(href, ng-click="deleteAccount()") #{translate("delete_your_account")} + p.small + | #{translate("newsletter_info_and_unsubscribe")} + a( + href, + ng-click="unsubscribe()", + ng-show="subscribed && !unsubscribing" + ) #{translate("unsubscribe")} + span( + ng-show="unsubscribing" + ) + i.fa.fa-spin.fa-refresh + | #{translate("unsubscribing")} + span.text-success( + ng-show="!subscribed" + ) + i.fa.fa-check + | #{translate("unsubscribed")} + + p #{translate("need_to_leave")} + a(href, ng-click="deleteAccount()") #{translate("delete_your_account")} script(type='text/ng-template', id='deleteAccountModalTemplate')