mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-05-28 13:02:35 +02:00
Merge branch 'master' of https://github.com/CryptofyCH/apolloapi
This commit is contained in:
commit
2dbcfe297c
@ -1,6 +1,6 @@
|
||||
const config = require('config')
|
||||
|
||||
module.exports = {
|
||||
client: 'pg',
|
||||
client: 'sqlite',
|
||||
connection: config.get('db.url')
|
||||
}
|
||||
|
21
src/graphql/graphqlModules/Auth/AuthChangePassword.js
Normal file
21
src/graphql/graphqlModules/Auth/AuthChangePassword.js
Normal file
@ -0,0 +1,21 @@
|
||||
module.exports.typeDefs = `
|
||||
type AuthActions {
|
||||
changePassword (input: AuthChangePasswordInput!): AuthChangePasswordOutput!
|
||||
}
|
||||
|
||||
input AuthChangePasswordInput {
|
||||
password: String!
|
||||
}
|
||||
|
||||
type AuthChangePasswordOutput {
|
||||
error: Error
|
||||
}
|
||||
`
|
||||
|
||||
module.exports.resolvers = {
|
||||
AuthActions: {
|
||||
changePassword (root, args, { dispatch }) {
|
||||
return dispatch('api/auth/changePassword', args.input)
|
||||
}
|
||||
}
|
||||
}
|
14
src/store/api/auth/authChangePassword.js
Normal file
14
src/store/api/auth/authChangePassword.js
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = ({ define }) => {
|
||||
define('changePassword', async ({ password }, { knex, errors, utils }) => {
|
||||
// TODO transaction
|
||||
const [ setup ] = await knex('setup').select('*').limit(1)
|
||||
if (!setup) {
|
||||
throw new errors.AuthorizationError('Setup not finished')
|
||||
}
|
||||
await knex('setup').update({
|
||||
password: await utils.auth.hashPassword(password)
|
||||
})
|
||||
}, {
|
||||
auth: true
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user