From 91fc8a65a28e5dc682adc10079b005547a4090cc Mon Sep 17 00:00:00 2001 From: garrettmills Date: Wed, 10 Mar 2021 19:43:51 -0600 Subject: [PATCH] Allow users to set login shell in profile --- .../app/dash/profile/EditProfile.component.js | 21 ++++++++++++++++++- app/assets/app/service/Profile.service.js | 4 ++-- app/controllers/api/v1/Profile.controller.js | 4 +++- app/models/auth/User.model.js | 3 ++- locale/en_US/profile.locale.js | 3 +++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/assets/app/dash/profile/EditProfile.component.js b/app/assets/app/dash/profile/EditProfile.component.js index bbef1ae..e2d3d1a 100644 --- a/app/assets/app/dash/profile/EditProfile.component.js +++ b/app/assets/app/dash/profile/EditProfile.component.js @@ -77,6 +77,20 @@ const template = ` > +
+

{{ t['profile.advanced_header'] }}

+
+ + +
+
  • {{ form_message }} @@ -202,6 +216,7 @@ export default class EditProfileComponent extends Component { this.profile_last = '' this.profile_email = '' this.profile_tagline = '' + this.profile_shell = '' this.last_reset = '' this.mfa_enable_date = '' @@ -271,7 +286,9 @@ export default class EditProfileComponent extends Component { 'profile.app_key', 'profile.example_gateway_url', 'profile.save_notify', - 'profile.test_notify' + 'profile.test_notify', + 'profile.advanced_header', + 'profile.advanced_shell' ) this.app_name = session.get('app.name') @@ -292,6 +309,7 @@ export default class EditProfileComponent extends Component { last_name: this.profile_last, email: this.profile_email, tagline: this.profile_tagline, + login_shell: this.profile_shell, user_id: this.user_id || 'me', } } @@ -340,6 +358,7 @@ export default class EditProfileComponent extends Component { this.profile_last = result.last_name this.profile_email = result.email this.profile_tagline = result.tagline + this.profile_shell = result.login_shell const notify_config = await profile_service.get_notify(this.user_id || 'me') if ( !notify_config || !notify_config.has_config ) { diff --git a/app/assets/app/service/Profile.service.js b/app/assets/app/service/Profile.service.js index 04a21f4..5c41590 100644 --- a/app/assets/app/service/Profile.service.js +++ b/app/assets/app/service/Profile.service.js @@ -10,8 +10,8 @@ class ProfileService { if ( results && results.data && results.data.data ) return results.data.data } - async update_profile({ user_id, first_name, last_name, email, tagline = undefined }) { - await axios.patch(`/api/v1/profile/${user_id}`, { first_name, last_name, email, tagline }) + async update_profile({ user_id, first_name, last_name, email, login_shell = undefined, tagline = undefined }) { + await axios.patch(`/api/v1/profile/${user_id}`, { first_name, last_name, email, tagline, login_shell }) } async update_notify({ user_id = 'me', app_key, gateway_url }) { diff --git a/app/controllers/api/v1/Profile.controller.js b/app/controllers/api/v1/Profile.controller.js index 565fb6c..742ce26 100644 --- a/app/controllers/api/v1/Profile.controller.js +++ b/app/controllers/api/v1/Profile.controller.js @@ -24,8 +24,9 @@ class ProfileController extends Controller { last_name: user.last_name, email: user.email, uid: user.uid, - tagline: user.tagline, + tagline: user.tagline || '', user_id: user.id, + login_shell: user.login_shell || '', ...(user.notify_config ? { notify_config: await user.notify_config.to_api() } : {}) }) } @@ -158,6 +159,7 @@ class ProfileController extends Controller { user.last_name = req.body.last_name user.email = req.body.email user.tagline = req.body.tagline + user.login_shell = req.body.login_shell // Save the record await user.save() diff --git a/app/models/auth/User.model.js b/app/models/auth/User.model.js index b73b523..dacfce6 100644 --- a/app/models/auth/User.model.js +++ b/app/models/auth/User.model.js @@ -39,6 +39,7 @@ class User extends AuthUser { trap: String, notify_config: NotifyConfig, uid_number: Number, + login_shell: String, }} } @@ -190,7 +191,7 @@ class User extends AuthUser { const Policy = this.models.get('iam:Policy') const uid_number = await this.get_uid_number() - const shell = this.configs.get('ldap:server.schema.default_shell') + const shell = this.login_shell || this.configs.get('ldap:server.schema.default_shell') const domain = this.configs.get('ldap:server.schema.base_dc').split(',').map(x => x.replace('dc=', '')).join('.') const ldap_data = { diff --git a/locale/en_US/profile.locale.js b/locale/en_US/profile.locale.js index d58e171..3b211e3 100644 --- a/locale/en_US/profile.locale.js +++ b/locale/en_US/profile.locale.js @@ -51,4 +51,7 @@ module.exports = exports = { mfa_1: 'MFA is a good-practice security measure that requires you to provide a second factor of identification when you sign in from a service or device that makes use of APP_NAME.', mfa_2: 'Once enabled, APP_NAME will prompt you to enter a code when you sign-in with the APP_NAME web interface from a new device. It will also require you to append the code to your password when signing in to a service that uses APP_NAME as a backend.', + + advanced_header: 'Advanced', + advanced_shell: 'Default Login Shell', }