aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--src/boot/after_store.js2
-rw-r--r--src/components/login_form/login_form.js26
-rw-r--r--src/components/login_form/login_form.vue19
-rw-r--r--src/modules/instance.js1
-rw-r--r--static/config.json3
6 files changed, 47 insertions, 10 deletions
diff --git a/README.md b/README.md
index 5a3e2a4b..b6e5a586 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 65d1ea02..6b8aef7f 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 ffdd5504..49868aed 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 db389716..8a5174d7 100644
--- a/src/components/login_form/login_form.vue
+++ b/src/components/login_form/login_form.vue
@@ -5,7 +5,24 @@
{{$t('login.login')}}
</div>
<div class="panel-body">
- <form v-on:submit.prevent='oAuthLogin' class="login-form">
+ <form v-if="loginMethod == 'password'" v-on:submit.prevent='submit(user)' class='login-form'>
+ <div class='form-group'>
+ <label for='username'>{{$t('login.username')}}</label>
+ <input :disabled="loggingIn" v-model='user.username' class='form-control' id='username' v-bind:placeholder="$t('login.placeholder')">
+ </div>
+ <div class='form-group'>
+ <label for='password'>{{$t('login.password')}}</label>
+ <input :disabled="loggingIn" v-model='user.password' class='form-control' id='password' type='password'>
+ </div>
+ <div class='form-group'>
+ <div class='login-bottom'>
+ <div><router-link :to="{name: 'registration'}" v-if='registrationOpen' class='register'>{{$t('login.register')}}</router-link></div>
+ <button :disabled="loggingIn" type='submit' class='btn btn-default'>{{$t('login.login')}}</button>
+ </div>
+ </div>
+ </form>
+
+ <form v-if="loginMethod == 'token'" v-on:submit.prevent='oAuthLogin' class="login-form">
<div class='form-group'>
<div class='login-bottom'>
<div><router-link :to="{name: 'registration'}" v-if='registrationOpen' class='register'>{{$t('login.register')}}</router-link></div>
diff --git a/src/modules/instance.js b/src/modules/instance.js
index d61ca842..8b2c03d2 100644
--- a/src/modules/instance.js
+++ b/src/modules/instance.js
@@ -21,6 +21,7 @@ const defaultState = {
hidePostStats: false,
hideUserStats: false,
disableChat: false,
+ loginMethod: 'password',
// Nasty stuff
pleromaBackend: true,
diff --git a/static/config.json b/static/config.json
index a6eace0f..69a70741 100644
--- a/static/config.json
+++ b/static/config.json
@@ -12,5 +12,6 @@
"formattingOptionsEnabled": false,
"collapseMessageWithSubject": false,
"hidePostStats": false,
- "hideUserStats": false
+ "hideUserStats": false,
+ "loginMethod": "password"
}