use oauth2 password flow for webclient

This commit is contained in:
les
2020-01-27 00:47:03 +01:00
parent 6352cb3d12
commit b706333c85
21 changed files with 367 additions and 448 deletions

View File

@@ -22,7 +22,7 @@
</template>
<script>
import { mapActions, mapState } from 'vuex'
import { mapState } from 'vuex'
import { Message } from 'element-ui'
import get from 'lodash/get'
@@ -45,10 +45,6 @@ export default {
this.$refs.email.focus()
},
methods: {
...mapActions(['login']),
close () {
this.$router.replace('/')
},
async forgot () {
if (!this.email) {
Message({ message: this.$t('login.insert_email'), showClose: true, type: 'error' })
@@ -65,10 +61,15 @@ export default {
e.preventDefault()
try {
this.loading = true
await this.$auth.loginWith('local', { data: { email: this.email, password: this.password } })
const data = new URLSearchParams()
data.append('username', this.email)
data.append('password', this.password)
data.append('grant_type', 'password')
data.append('client_id', 'self')
await this.$auth.loginWith('local', { data })
this.loading = false
Message({ message: this.$t('login.ok'), showClose: true, type: 'success' })
this.close()
this.$router.replace('/')
} catch (e) {
Message({ message: this.$t('login.error') + this.$t(get(e, 'response.data.message', e)), showClose: true, type: 'error' })
this.loading = false