Skip to content
Snippets Groups Projects
Commit 22a7a816 authored by Maxim Filippov's avatar Maxim Filippov :new_moon_with_face:
Browse files

`mailerEnabled` must be set to `true` in order to require password reset...

`mailerEnabled` must be set to `true` in order to require password reset (password reset currently only works via email)
parent 6290d06e
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !51. Comments created here will be created in the context of that merge request.
......@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased
### Changed
- `mailerEnabled` must be set to `true` in order to require password reset (password reset currently only works via email)
## [1.2.0] - 2019-09-27
### Added
......
import request from '@/utils/request'
import { baseName } from './utils'
export async function getNodeInfo(authHost) {
return await request({
baseURL: baseName(authHost),
url: `/nodeinfo/2.0.json`,
method: 'get'
})
}
......@@ -215,6 +215,7 @@ export default {
addTagForMultipleUsersConfirmation: 'Are you sure you want to apply tag to all selected users?',
removeTagFromMultipleUsersConfirmation: 'Are you sure you want to remove tag from all selected users?',
requirePasswordResetConfirmation: 'Are you sure you want to require password reset for all selected users?',
mailerMustBeEnabled: 'To require user\'s password reset you must enable mailer.',
ok: 'Okay',
completed: 'Completed',
cancel: 'Cancel',
......
......@@ -27,6 +27,7 @@ export const beforeEachRoute = (to, from, next) => {
if (store.getters.roles.length === 0) {
store.dispatch('GetUserInfo').then(res => {
const roles = res.data.pleroma.is_admin ? ['admin'] : []
store.dispatch('GetNodeInfo')
store.dispatch('GenerateRoutes', { roles }).then(() => {
router.addRoutes(store.getters.addRouters)
next({ ...to, replace: true })
......
import { loginByUsername, getUserInfo } from '@/api/login'
import { getNodeInfo } from '@/api/nodeInfo'
import { getToken, setToken, removeToken, getAuthHost, setAuthHost, removeAuthHost } from '@/utils/auth'
const user = {
......@@ -15,7 +16,8 @@ const user = {
roles: [],
setting: {
articlePlatform: []
}
},
nodeInfo: {}
},
mutations: {
......@@ -48,6 +50,9 @@ const user = {
},
SET_AUTH_HOST: (state, authHost) => {
state.authHost = authHost
},
SET_NODE_INFO: (state, nodeInfo) => {
state.nodeInfo = nodeInfo
}
},
......@@ -67,7 +72,11 @@ const user = {
})
})
},
async GetNodeInfo({ commit, state }) {
const nodeInfo = await getNodeInfo(state.authHost)
commit('SET_NODE_INFO', nodeInfo.data)
},
GetUserInfo({ commit, state }) {
return new Promise((resolve, reject) => {
getUserInfo(state.token, state.authHost).then(response => {
......
......@@ -273,6 +273,14 @@ export default {
)
},
requirePasswordReset() {
const mailerEnabled = this.$store.state.user.nodeInfo.metadata.mailerEnabled
if (!mailerEnabled) {
this.$alert(this.$t('users.mailerMustBeEnabled'), 'Error', { type: 'error' })
return
}
const { requirePasswordReset } = this.mappers()
this.confirmMessage(
this.$t('users.requirePasswordResetConfirmation'),
......
......@@ -265,6 +265,14 @@ export default {
this.$store.dispatch('GetPasswordResetToken', nickname)
},
requirePasswordReset(nickname) {
const mailerEnabled = this.$store.state.user.nodeInfo.metadata.mailerEnabled
if (!mailerEnabled) {
this.$alert(this.$t('users.mailerMustBeEnabled'), 'Error', { type: 'error' })
return
}
this.$store.dispatch('RequirePasswordReset', { nickname })
},
handleDeactivation({ nickname }) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment