1
0
mirror of https://git.pleroma.social/sjw/pleroma-fe.git synced 2024-11-15 10:06:49 +01:00

update init LoginMethod

This commit is contained in:
Maksim Pechnikov 2019-06-06 22:19:07 +03:00
parent 0d31704c95
commit b9a64a523e
3 changed files with 11 additions and 14 deletions

View File

@ -92,6 +92,7 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
? 0
: config.logoMargin
})
store.commit('authFlow/setInitialStrategy', config['loginMethod@'])
copyInstanceOption('redirectRootNoLogin')
copyInstanceOption('redirectRootLogin')
@ -100,7 +101,6 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => {
copyInstanceOption('formattingOptionsEnabled')
copyInstanceOption('hideMutedPosts')
copyInstanceOption('collapseMessageWithSubject')
copyInstanceOption('loginMethod')
copyInstanceOption('scopeCopy')
copyInstanceOption('subjectLineBehavior')
copyInstanceOption('postContentType')

View File

@ -5,16 +5,11 @@ const TOKEN_STRATEGY = 'token'
const TOTP_STRATEGY = 'totp'
const RECOVERY_STRATEGY = 'recovery'
const fetchStrategy = (state, rootState) => {
return state.strategy || rootState.instance.loginMethod || PASSWORD_STRATEGY
}
// initial state
const state = {
app: null,
settings: {},
strategy: null
strategy: PASSWORD_STRATEGY
}
// getters
@ -26,21 +21,24 @@ const getters = {
return state.settings
},
requiredPassword: (state, getters, rootState) => {
return fetchStrategy(state, rootState) === PASSWORD_STRATEGY
return state.strategy === PASSWORD_STRATEGY
},
requiredToken: (state, getters, rootState) => {
return fetchStrategy(state, rootState) === TOKEN_STRATEGY
return state.strategy === TOKEN_STRATEGY
},
requiredTOTP: (state, getters, rootState) => {
return fetchStrategy(state, rootState) === TOTP_STRATEGY
return state.strategy === TOTP_STRATEGY
},
requiredRecovery: (state, getters, rootState) => {
return fetchStrategy(state, rootState) === RECOVERY_STRATEGY
return state.strategy === RECOVERY_STRATEGY
}
}
// mutations
const mutations = {
setInitialStrategy (state, strategy) {
if (strategy) { state.strategy = strategy }
},
requirePassword (state) {
state.strategy = PASSWORD_STRATEGY
},
@ -50,7 +48,7 @@ const mutations = {
requireMFA (state, {app, settings}) {
state.settings = settings
state.app = app
state.strategy = TOTP_STRATEGY
state.strategy = TOTP_STRATEGY // default strategy of MFA
},
requireRecovery (state) {
state.strategy = RECOVERY_STRATEGY
@ -59,7 +57,7 @@ const mutations = {
state.strategy = TOTP_STRATEGY
},
reset (state) {
state.strategy = null
state.strategy = PASSWORD_STRATEGY
state.settings = {}
state.app = null
}

View File

@ -27,7 +27,6 @@ const defaultState = {
scopeCopy: true,
subjectLineBehavior: 'email',
postContentType: 'text/plain',
loginMethod: 'password',
nsfwCensorImage: undefined,
vapidPublicKey: undefined,
noAttachmentLinks: false,