2019-03-02 11:25:10 +01:00
|
|
|
import AbstractService from './abstractService'
|
|
|
|
import PasswordResetModel from '../models/passwordReset'
|
|
|
|
|
|
|
|
export default class PasswordResetService extends AbstractService {
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super({})
|
|
|
|
this.paths = {
|
|
|
|
reset: '/user/password/reset',
|
|
|
|
requestReset: '/user/password/token',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
modelFactory(data) {
|
|
|
|
return new PasswordResetModel(data)
|
|
|
|
}
|
|
|
|
|
2021-10-11 19:37:20 +02:00
|
|
|
async resetPassword(model) {
|
2019-03-02 11:25:10 +01:00
|
|
|
const cancel = this.setLoading()
|
2021-10-11 19:37:20 +02:00
|
|
|
try {
|
|
|
|
const response = await this.http.post(this.paths.reset, model)
|
|
|
|
return this.modelFactory(response.data)
|
|
|
|
} finally {
|
|
|
|
cancel()
|
|
|
|
}
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
|
|
|
|
2021-10-11 19:37:20 +02:00
|
|
|
async requestResetPassword(model) {
|
2019-03-02 11:25:10 +01:00
|
|
|
const cancel = this.setLoading()
|
2021-10-11 19:37:20 +02:00
|
|
|
try {
|
|
|
|
const response = await this.http.post(this.paths.requestReset, model)
|
|
|
|
return this.modelFactory(response.data)
|
|
|
|
} finally {
|
|
|
|
cancel()
|
|
|
|
}
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
|
|
|
}
|