Page MenuHomePhorge

No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None
diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js
index 603f486653..1119754eb0 100644
--- a/src/components/login_form/login_form.js
+++ b/src/components/login_form/login_form.js
@@ -1,76 +1,75 @@
import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
import oauthApi from '../../services/new_api/oauth.js'
const LoginForm = {
data: () => ({
user: {},
error: false
}),
computed: {
isPasswordAuth () { return this.requiredPassword },
isTokenAuth () { return this.requiredToken },
...mapState({
registrationOpen: state => state.instance.registrationOpen,
instance: state => state.instance,
loggingIn: state => state.users.loggingIn,
oauth: state => state.oauth
}),
...mapGetters(
'authFlow', ['requiredPassword', 'requiredToken', 'requiredMFA']
)
},
methods: {
- ...mapMutations('authFlow', ['requireMFA', 'setupMFA']),
+ ...mapMutations('authFlow', ['requireMFA']),
...mapActions({ login: 'authFlow/login' }),
submit () {
this.isTokenMethod ? this.submitToken() : this.submitPassword()
},
submitToken () {
oauthApi.login({
oauth: this.oauth,
instance: this.instance.server,
commit: this.$store.commit
})
},
submitPassword () {
const data = {
oauth: this.oauth,
instance: this.instance.server
}
this.error = false
oauthApi.getOrCreateApp(data).then((app) => {
oauthApi.getTokenWithCredentials(
{
app,
instance: data.instance,
username: this.user.username,
password: this.user.password
}
).then((result) => {
if (result.error) {
if (result.error === 'mfa_required') {
- this.setupMFA({app: app, settings: result})
- this.requireMFA()
+ this.requireMFA({app: app, settings: result})
} else {
this.error = result.error
this.focusOnPasswordInput()
}
return
}
this.login(result).then(() => {
this.$router.push({name: 'friends'})
})
})
})
},
clearError () { this.error = false },
focusOnPasswordInput () {
let passwordInput = this.$refs.passwordInput
passwordInput.focus()
passwordInput.setSelectionRange(0, passwordInput.value.length)
}
}
}
export default LoginForm
diff --git a/src/modules/auth_flow.js b/src/modules/auth_flow.js
index b03b4c90f2..01ec17e24a 100644
--- a/src/modules/auth_flow.js
+++ b/src/modules/auth_flow.js
@@ -1,94 +1,83 @@
const PASSWORD_STRATEGY = 'password'
const TOKEN_STRATEGY = 'token'
// MFA strategies
const TOTP_STRATEGY = 'totp'
const RECOVERY_STRATEGY = 'recovery'
const fetchStrategy = (state, rootState) => {
- if (state.requiredMFA) {
- return state.strategy || TOTP_STRATEGY
- } else {
- return state.strategy || rootState.instance.loginMethod || PASSWORD_STRATEGY
- }
+ return state.strategy || rootState.instance.loginMethod || PASSWORD_STRATEGY
}
// initial state
const state = {
app: null,
settings: {},
- requiredMFA: false,
strategy: null
}
// getters
const getters = {
app: (state, getters) => {
return state.app
},
settings: (state, getters) => {
return state.settings
},
requiredPassword: (state, getters, rootState) => {
return fetchStrategy(state, rootState) === PASSWORD_STRATEGY
},
requiredToken: (state, getters, rootState) => {
return fetchStrategy(state, rootState) === TOKEN_STRATEGY
},
requiredTOTP: (state, getters, rootState) => {
- return state.requiredMFA &&
- fetchStrategy(state, rootState) === TOTP_STRATEGY
+ return fetchStrategy(state, rootState) === TOTP_STRATEGY
},
requiredRecovery: (state, getters, rootState) => {
- return state.requiredMFA &&
- fetchStrategy(state, rootState) === RECOVERY_STRATEGY
+ return fetchStrategy(state, rootState) === RECOVERY_STRATEGY
}
}
// mutations
const mutations = {
requirePassword (state) {
state.strategy = PASSWORD_STRATEGY
},
requireToken (state) {
state.strategy = TOKEN_STRATEGY
},
- setupMFA (state, {app, settings}) { // sets MFA settings (token, supported strategies)
+ requireMFA (state, {app, settings}) {
state.settings = settings
state.app = app
- },
- requireMFA (state) {
- state.requiredMFA = true
state.strategy = TOTP_STRATEGY
},
requireRecovery (state) {
state.strategy = RECOVERY_STRATEGY
},
requireTOTP (state) {
state.strategy = TOTP_STRATEGY
},
reset (state) {
- state.requiredMFA = false
state.strategy = null
state.settings = {}
state.app = null
}
}
// actions
const actions = {
async login ({state, dispatch, commit}, {access_token}) {
commit('setToken', access_token, { root: true })
await dispatch('loginUser', access_token, { root: true })
commit('reset')
}
}
export default {
namespaced: true,
state,
getters,
mutations,
actions
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Aug 30, 9:19 PM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1738165
Default Alt Text
(5 KB)

Event Timeline