From ae60352c16a096e1bad9cc3b2409bd28fa591404 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Fri, 3 Mar 2017 13:24:43 +0000 Subject: [PATCH] disable email input field when using OAuth, direct users to my.ghost.org for login details (#560) no issue - disables user email input field when using Ghost OAuth because email addresses are synced from the central identity management system - adds a link to my.ghost.org account management when using Ghost OAuth and viewing your own user --- ghost/admin/app/controllers/team/user.js | 13 +++++++++++-- ghost/admin/app/styles/patterns/boxes.css | 1 + ghost/admin/app/templates/team/user.hbs | 11 +++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ghost/admin/app/controllers/team/user.js b/ghost/admin/app/controllers/team/user.js index 6f317429cb..30695d1204 100644 --- a/ghost/admin/app/controllers/team/user.js +++ b/ghost/admin/app/controllers/team/user.js @@ -43,8 +43,17 @@ export default Controller.extend({ rolesDropdownIsVisible: and('isNotOwnProfile', 'canAssignRoles', 'isNotOwnersProfile'), userActionsAreVisible: or('deleteUserActionIsVisible', 'canMakeOwner'), - isNotOwnProfile: computed('user.id', 'currentUser.id', function () { - return this.get('user.id') !== this.get('currentUser.id'); + isOwnProfile: computed('user.id', 'currentUser.id', function () { + return this.get('user.id') === this.get('currentUser.id'); + }), + isNotOwnProfile: not('isOwnProfile'), + showMyGhostLink: and('config.ghostOAuth', 'isOwnProfile'), + + canChangeEmail: computed('config.ghostOAuth', 'isAdminUserOnOwnerProfile', function () { + let ghostOAuth = this.get('config.ghostOAuth'); + let isAdminUserOnOwnerProfile = this.get('isAdminUserOnOwnerProfile'); + + return !ghostOAuth && !isAdminUserOnOwnerProfile; }), deleteUserActionIsVisible: computed('currentUser', 'canAssignRoles', 'user', function () { diff --git a/ghost/admin/app/styles/patterns/boxes.css b/ghost/admin/app/styles/patterns/boxes.css index 8bc857e5c0..06cb0b28b7 100644 --- a/ghost/admin/app/styles/patterns/boxes.css +++ b/ghost/admin/app/styles/patterns/boxes.css @@ -2,6 +2,7 @@ /* ---------------------------------------------------------- */ .gh-box { + position: relative; padding: 12px 10px 14px 40px; border: 1px solid var(--lightgrey); border-left-width: 5px; diff --git a/ghost/admin/app/templates/team/user.hbs b/ghost/admin/app/templates/team/user.hbs index 2d337ab4d7..42003cd319 100644 --- a/ghost/admin/app/templates/team/user.hbs +++ b/ghost/admin/app/templates/team/user.hbs @@ -104,12 +104,12 @@ {{#gh-form-group errors=user.errors hasValidated=user.hasValidated property="email"}} {{!-- Administrators only see text of Owner's email address but not input --}} - {{#unless isAdminUserOnOwnerProfile}} + {{#if canChangeEmail}} {{gh-input user.email type="email" id="user-email" name="email" placeholder="Email Address" autocapitalize="off" autocorrect="off" autocomplete="off" focusOut=(action "validate" "email" target=user) update=(action (mut user.email))}} {{gh-error-message errors=user.errors property="email"}} {{else}} {{user.email}} - {{/unless}} + {{/if}}

Used for notifications

{{/gh-form-group}} @@ -204,5 +204,12 @@ {{! change password form }} {{/if}} + + {{!-- when using Ghost OAuth, users trying to change email/pass need to visit my.ghost.org --}} + {{#if showMyGhostLink}} +
+

To change your login details please visit https://my.ghost.org/account

+
+ {{/if}}