diff --git a/README.md b/README.md index 5a3e2a4bec..b6e5a58632 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,9 @@ npm run unit # Configuration Edit config.json for configuration. scopeOptionsEnabled gives you input fields for CWs and the scope settings. + +## Options + +### Login methods + +```loginMethod``` can be set to either ```password``` (the default) or ```token```, which will use the full oauth redirection flow, which is useful for SSO situations. diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 65d1ea0220..6b8aef7f05 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -53,6 +53,7 @@ const afterStoreSetup = ({store, i18n}) => { var scopeOptionsEnabled = (config.scopeOptionsEnabled) var formattingOptionsEnabled = (config.formattingOptionsEnabled) var collapseMessageWithSubject = (config.collapseMessageWithSubject) + var loginMethod = (config.loginMethod) store.dispatch('setInstanceOption', { name: 'theme', value: theme }) store.dispatch('setInstanceOption', { name: 'background', value: background }) @@ -67,6 +68,7 @@ const afterStoreSetup = ({store, i18n}) => { store.dispatch('setInstanceOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled }) store.dispatch('setInstanceOption', { name: 'formattingOptionsEnabled', value: formattingOptionsEnabled }) store.dispatch('setInstanceOption', { name: 'collapseMessageWithSubject', value: collapseMessageWithSubject }) + store.dispatch('setInstanceOption', { name: 'loginMethod', value: loginMethod }) if (chatDisabled) { store.dispatch('disableChat') } diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js index ffdd550401..49868aed10 100644 --- a/src/components/login_form/login_form.js +++ b/src/components/login_form/login_form.js @@ -5,6 +5,7 @@ const LoginForm = { authError: false }), computed: { + loginMethod () { return this.$store.state.instance.loginMethod }, loggingIn () { return this.$store.state.users.loggingIn }, registrationOpen () { return this.$store.state.instance.registrationOpen } }, @@ -17,14 +18,23 @@ const LoginForm = { }) }, submit () { - this.$store.dispatch('loginUser', this.user).then( - () => {}, - (error) => { - this.authError = error - this.user.username = '' - this.user.password = '' - } - ) + const data = { + oauth: this.$store.state.oauth, + instance: this.$store.state.instance.server + } + oauthApi.getOrCreateApp(data).then((app) => { + oauthApi.getTokenWithCredentials( + { + app, + instance: data.instance, + username: this.user.username, + password: this.user.password}) + .then((result) => { + this.$store.commit('setToken', result.access_token) + this.$store.dispatch('loginUser', result.access_token) + this.$router.push('/main/friends') + }) + }) } } } diff --git a/src/components/login_form/login_form.vue b/src/components/login_form/login_form.vue index db3897161e..8a5174d731 100644 --- a/src/components/login_form/login_form.vue +++ b/src/components/login_form/login_form.vue @@ -5,7 +5,24 @@ {{$t('login.login')}}
-
+ +
+ + +
+
+ + +
+
+ +
+
+ +