Merge branch 'fix-token-auth-login' into 'develop'
Fix broken token authentication See merge request pleroma/pleroma-fe!846
This commit is contained in:
commit
5a8f3dddfd
|
@ -26,9 +26,10 @@ const LoginForm = {
|
||||||
this.isTokenAuth ? this.submitToken() : this.submitPassword()
|
this.isTokenAuth ? this.submitToken() : this.submitPassword()
|
||||||
},
|
},
|
||||||
submitToken () {
|
submitToken () {
|
||||||
const { clientId } = this.oauth
|
const { clientId, clientSecret } = this.oauth
|
||||||
const data = {
|
const data = {
|
||||||
clientId,
|
clientId,
|
||||||
|
clientSecret,
|
||||||
instance: this.instance.server,
|
instance: this.instance.server,
|
||||||
commit: this.$store.commit
|
commit: this.$store.commit
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,11 @@ const oac = {
|
||||||
props: ['code'],
|
props: ['code'],
|
||||||
mounted () {
|
mounted () {
|
||||||
if (this.code) {
|
if (this.code) {
|
||||||
const { clientId } = this.$store.state.oauth
|
const { clientId, clientSecret } = this.$store.state.oauth
|
||||||
|
|
||||||
oauth.getToken({
|
oauth.getToken({
|
||||||
clientId,
|
clientId,
|
||||||
|
clientSecret,
|
||||||
instance: this.$store.state.instance.server,
|
instance: this.$store.state.instance.server,
|
||||||
code: this.code
|
code: this.code
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
|
|
|
@ -19,7 +19,8 @@ const saveImmedeatelyActions = [
|
||||||
'setHighlight',
|
'setHighlight',
|
||||||
'setOption',
|
'setOption',
|
||||||
'setClientData',
|
'setClientData',
|
||||||
'setToken'
|
'setToken',
|
||||||
|
'clearToken'
|
||||||
]
|
]
|
||||||
|
|
||||||
const defaultStorage = (() => {
|
const defaultStorage = (() => {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const chat = {
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
disconnectFromChat (store) {
|
disconnectFromChat (store) {
|
||||||
store.state.socket.disconnect()
|
store.state.socket && store.state.socket.disconnect()
|
||||||
},
|
},
|
||||||
initializeChat (store, socket) {
|
initializeChat (store, socket) {
|
||||||
const channel = socket.channel('chat:public')
|
const channel = socket.channel('chat:public')
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { delete as del } from 'vue'
|
||||||
|
|
||||||
const oauth = {
|
const oauth = {
|
||||||
state: {
|
state: {
|
||||||
clientId: false,
|
clientId: false,
|
||||||
|
@ -22,6 +24,12 @@ const oauth = {
|
||||||
},
|
},
|
||||||
setToken (state, token) {
|
setToken (state, token) {
|
||||||
state.userToken = token
|
state.userToken = token
|
||||||
|
},
|
||||||
|
clearToken (state) {
|
||||||
|
state.userToken = false
|
||||||
|
// state.token is userToken with older name, coming from persistent state
|
||||||
|
// let's clear it as well, since it is being used as a fallback of state.userToken
|
||||||
|
del(state, 'token')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
|
|
@ -399,7 +399,7 @@ const users = {
|
||||||
logout (store) {
|
logout (store) {
|
||||||
store.commit('clearCurrentUser')
|
store.commit('clearCurrentUser')
|
||||||
store.dispatch('disconnectFromChat')
|
store.dispatch('disconnectFromChat')
|
||||||
store.commit('setToken', false)
|
store.commit('clearToken')
|
||||||
store.dispatch('stopFetching', 'friends')
|
store.dispatch('stopFetching', 'friends')
|
||||||
store.commit('setBackendInteractor', backendInteractorService(store.getters.getToken()))
|
store.commit('setBackendInteractor', backendInteractorService(store.getters.getToken()))
|
||||||
store.dispatch('stopFetching', 'notifications')
|
store.dispatch('stopFetching', 'notifications')
|
||||||
|
|
Loading…
Reference in New Issue