summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorguillaume <guillaume.cassou@supinfo.com>2018-10-09 14:14:39 +0200
committerguillaume <guillaume.cassou@supinfo.com>2018-10-09 14:14:39 +0200
commit3b4f285fea4a90ee96bfce855e1539adcec9b7aa (patch)
tree61cbf1212c8d4052cf2bd3c37a497f1d8b204140 /client
parent5b8c642d8fb16e00000a1d92bcd3a5c6bbd07bce (diff)
downloadwekan-3b4f285fea4a90ee96bfce855e1539adcec9b7aa.tar.gz
wekan-3b4f285fea4a90ee96bfce855e1539adcec9b7aa.tar.bz2
wekan-3b4f285fea4a90ee96bfce855e1539adcec9b7aa.zip
add ldap support | simplify authentications
Diffstat (limited to 'client')
-rw-r--r--client/components/main/layouts.js48
-rw-r--r--client/components/settings/connectionMethod.jade8
-rw-r--r--client/components/settings/connectionMethod.js22
-rw-r--r--client/components/settings/peopleBody.jade22
-rw-r--r--client/components/settings/peopleBody.js31
5 files changed, 97 insertions, 34 deletions
diff --git a/client/components/main/layouts.js b/client/components/main/layouts.js
index 1d3c3690..6d1f95d4 100644
--- a/client/components/main/layouts.js
+++ b/client/components/main/layouts.js
@@ -6,7 +6,23 @@ const i18nTagToT9n = (i18nTag) => {
return i18nTag;
};
+const validator = {
+ set: function(obj, prop, value) {
+ if (prop === 'state' && value !== 'signIn') {
+ $('.at-form-authentication').hide();
+ } else if (prop === 'state' && value === 'signIn') {
+ $('.at-form-authentication').show();
+ }
+ // The default behavior to store the value
+ obj[prop] = value;
+ // Indicate success
+ return true;
+ }
+};
+
Template.userFormsLayout.onRendered(() => {
+ AccountsTemplates.state.form.keys = new Proxy(AccountsTemplates.state.form.keys, validator);
+
const i18nTag = navigator.language;
if (i18nTag) {
T9n.setLanguage(i18nTagToT9n(i18nTag));
@@ -65,37 +81,37 @@ Template.userFormsLayout.events({
}
});
},
- 'submit form'(event) {
- const connectionMethod = $('.select-connection').val();
-
+ 'click #at-btn'(event) {
+ /* All authentication method can be managed/called here.
+ !! DON'T FORGET to correctly fill the fields of the user during its creation if necessary authenticationMethod : String !!
+ */
+ const authenticationMethodSelected = $('.select-authentication').val();
// Local account
- if (connectionMethod === 'default') {
+ if (authenticationMethodSelected === 'password') {
return;
}
- // TODO : find a way to block "submit #at-pwd-form" of the at_pwd_form.js
+ // Stop submit #at-pwd-form
+ event.preventDefault();
+ event.stopImmediatePropagation();
- const inputs = event.target.getElementsByTagName('input');
-
- const email = inputs.namedItem('at-field-username_and_email').value;
- const password = inputs.namedItem('at-field-password').value;
+ const email = $('#at-field-username_and_email').val();
+ const password = $('#at-field-password').val();
// Ldap account
- if (connectionMethod === 'ldap') {
+ if (authenticationMethodSelected === 'ldap') {
// Check if the user can use the ldap connection
- Meteor.subscribe('user-connection-method', email, {
+ Meteor.subscribe('user-authenticationMethod', email, {
onReady() {
- const ldap = Users.findOne();
-
- if (ldap) {
+ const user = Users.findOne();
+ if (user === undefined || user.authenticationMethod === 'ldap') {
// Use the ldap connection package
Meteor.loginWithLDAP(email, password, function(error) {
if (!error) {
// Connection
return FlowRouter.go('/');
- } else {
- return error;
}
+ return error;
});
}
return this.stop();
diff --git a/client/components/settings/connectionMethod.jade b/client/components/settings/connectionMethod.jade
index 598dd9dd..ac4c8c64 100644
--- a/client/components/settings/connectionMethod.jade
+++ b/client/components/settings/connectionMethod.jade
@@ -1,6 +1,6 @@
template(name='connectionMethod')
- div.at-form-connection
- label Authentication method
- select.select-connection
- each connections
+ div.at-form-authentication
+ label {{_ 'authentication-method'}}
+ select.select-authentication
+ each authentications
option(value="{{value}}") {{_ value}}
diff --git a/client/components/settings/connectionMethod.js b/client/components/settings/connectionMethod.js
index 4983a3ef..3d5cfd76 100644
--- a/client/components/settings/connectionMethod.js
+++ b/client/components/settings/connectionMethod.js
@@ -1,20 +1,20 @@
Template.connectionMethod.onCreated(function() {
- this.connectionMethods = new ReactiveVar([]);
+ this.authenticationMethods = new ReactiveVar([]);
- Meteor.call('getConnectionsEnabled', (_, result) => {
+ Meteor.call('getAuthenticationsEnabled', (_, result) => {
if (result) {
// TODO : add a management of different languages
// (ex {value: ldap, text: TAPi18n.__('ldap', {}, T9n.getLanguage() || 'en')})
- this.connectionMethods.set([
- {value: 'default'},
- // Gets only the connection methods availables
+ this.authenticationMethods.set([
+ {value: 'password'},
+ // Gets only the authentication methods availables
...Object.entries(result).filter((e) => e[1]).map((e) => ({value: e[0]})),
]);
}
// If only the default authentication available, hides the select boxe
- const content = $('.at-form-connection');
- if (!(this.connectionMethods.get().length > 1)) {
+ const content = $('.at-form-authentication');
+ if (!(this.authenticationMethods.get().length > 1)) {
content.hide();
} else {
content.show();
@@ -24,11 +24,11 @@ Template.connectionMethod.onCreated(function() {
Template.connectionMethod.onRendered(() => {
// Moves the select boxe in the first place of the at-pwd-form div
- $('.at-form-connection').detach().prependTo('.at-pwd-form');
+ $('.at-form-authentication').detach().prependTo('.at-pwd-form');
});
Template.connectionMethod.helpers({
- connections() {
- return Template.instance().connectionMethods.get();
+ authentications() {
+ return Template.instance().authenticationMethods.get();
},
-});
+}); \ No newline at end of file
diff --git a/client/components/settings/peopleBody.jade b/client/components/settings/peopleBody.jade
index a3506a24..4d06637e 100644
--- a/client/components/settings/peopleBody.jade
+++ b/client/components/settings/peopleBody.jade
@@ -27,6 +27,7 @@ template(name="peopleGeneral")
th {{_ 'verified'}}
th {{_ 'createdAt'}}
th {{_ 'active'}}
+ th {{_ 'authentication-method'}}
th
each user in peopleList
+peopleRow(userId=user._id)
@@ -52,6 +53,7 @@ template(name="peopleRow")
| {{_ 'no'}}
else
| {{_ 'yes'}}
+ td {{_ userData.authenticationMethod }}
td
a.edit-user
| {{_ 'edit'}}
@@ -66,12 +68,18 @@ template(name="editUserPopup")
| {{_ 'username'}}
span.error.hide.username-taken
| {{_ 'error-username-taken'}}
- input.js-profile-username(type="text" value=user.username)
+ if isLdap
+ input.js-profile-username(type="text" value=user.username readonly)
+ else
+ input.js-profile-username(type="text" value=user.username)
label
| {{_ 'email'}}
span.error.hide.email-taken
| {{_ 'error-email-taken'}}
- input.js-profile-email(type="email" value="{{user.emails.[0].address}}")
+ if isLdap
+ input.js-profile-email(type="email" value="{{user.emails.[0].address}}" readonly)
+ else
+ input.js-profile-email(type="email" value="{{user.emails.[0].address}}")
label
| {{_ 'admin'}}
select.select-role.js-profile-isadmin
@@ -82,9 +90,17 @@ template(name="editUserPopup")
select.select-active.js-profile-isactive
option(value="false") {{_ 'yes'}}
option(value="true" selected="{{user.loginDisabled}}") {{_ 'no'}}
+ label
+ | {{_ 'authentication-type'}}
+ select.select-authenticationMethod.js-authenticationMethod
+ each authentications
+ if isSelected value
+ option(value="{{value}}" selected) {{_ value}}
+ else
+ option(value="{{value}}") {{_ value}}
hr
label
| {{_ 'password'}}
input.js-profile-password(type="password")
- input.primary.wide(type="submit" value="{{_ 'save'}}")
+ input.primary.wide(type="submit" value="{{_ 'save'}}") \ No newline at end of file
diff --git a/client/components/settings/peopleBody.js b/client/components/settings/peopleBody.js
index 7cc992f2..acc94081 100644
--- a/client/components/settings/peopleBody.js
+++ b/client/components/settings/peopleBody.js
@@ -62,10 +62,39 @@ Template.peopleRow.helpers({
},
});
+Template.editUserPopup.onCreated(function() {
+ this.authenticationMethods = new ReactiveVar([]);
+
+ Meteor.call('getAuthenticationsEnabled', (_, result) => {
+ if (result) {
+ // TODO : add a management of different languages
+ // (ex {value: ldap, text: TAPi18n.__('ldap', {}, T9n.getLanguage() || 'en')})
+ this.authenticationMethods.set([
+ {value: 'password'},
+ // Gets only the authentication methods availables
+ ...Object.entries(result).filter(e => e[1]).map(e => ({value: e[0]})),
+ ]);
+ }
+ });
+});
+
Template.editUserPopup.helpers({
user() {
return Users.findOne(this.userId);
},
+ authentications() {
+ return Template.instance().authenticationMethods.get();
+ },
+ isSelected(match) {
+ const userId = Template.instance().data.userId;
+ const selected = Users.findOne(userId).authenticationMethod;
+ return selected === match;
+ },
+ isLdap() {
+ const userId = Template.instance().data.userId;
+ const selected = Users.findOne(userId).authenticationMethod;
+ return selected === 'ldap';
+ }
});
BlazeComponent.extendComponent({
@@ -91,6 +120,7 @@ Template.editUserPopup.events({
const isAdmin = tpl.find('.js-profile-isadmin').value.trim();
const isActive = tpl.find('.js-profile-isactive').value.trim();
const email = tpl.find('.js-profile-email').value.trim();
+ const authentication = tpl.find('.js-authenticationMethod').value.trim();
const isChangePassword = password.length > 0;
const isChangeUserName = username !== user.username;
@@ -101,6 +131,7 @@ Template.editUserPopup.events({
'profile.fullname': fullname,
'isAdmin': isAdmin === 'true',
'loginDisabled': isActive === 'true',
+ 'authenticationMethod': authentication
},
});