Commit 41073145 authored by Shpuld Shpludson's avatar Shpuld Shpludson

Merge branch 'feat/forgot-password' into 'master'

Reset password

See merge request !41
parents 5dc5d4dd 2a7b69cd
Pipeline #29184 passed with stages
in 5 minutes and 7 seconds
import utils from './utils.js'
import utils, { queryParams } from './utils.js'
const createApp = async ({ config, params = {} }) => {
const defaults = {
......@@ -64,10 +64,19 @@ const getTokenWithPassword = async ({ config, params }) => {
})
}
const resetPassword = async ({ config, queries }) => {
return utils.request({
method: 'POST',
config,
url: `/auth/password?${queryParams(queries)}`
})
}
const oauth = {
createApp,
getTokenWithCode,
getTokenWithPassword
getTokenWithPassword,
resetPassword
}
export default oauth
import fetch from 'cross-fetch'
import parseLinkHeader from 'parse-link-header'
const queryParams = (params) => {
export const queryParams = (params) => {
return Object.keys(params)
.map(k => {
const field = params[k]
......@@ -42,16 +42,23 @@ const request = async ({ method = 'GET', url, params, queries, config, fullUrl =
body
})
let parsedResult = null
try {
parsedResult = await result.json()
} catch (e) {
parsedResult = result
}
if (result.ok) {
return {
state: 'ok',
data: await result.json(),
data: parsedResult,
links: parseLinkHeader(result.headers.get('link'))
}
} else {
return {
state: 'error',
data: await result.json()
data: parsedResult
}
}
} catch (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment