small fixes in /stores/user/duck/
parent
01584e640c
commit
954ab9c7a6
|
|
@ -8,14 +8,13 @@ import AppService from '../../AppService'
|
||||||
export default class UserService{
|
export default class UserService{
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private service: AppService
|
private service: AppService,
|
||||||
|
private serviceUser: User,
|
||||||
|
private response: any
|
||||||
){}
|
){}
|
||||||
|
|
||||||
private endpoint: string = 'user/'
|
private endpoint: string = 'user/'
|
||||||
private dispatch = useDispatch()
|
private dispatch: any = useDispatch()
|
||||||
private response: any
|
|
||||||
|
|
||||||
private serviceUser: User
|
|
||||||
|
|
||||||
// Authorization
|
// Authorization
|
||||||
|
|
||||||
|
|
@ -25,7 +24,7 @@ export default class UserService{
|
||||||
password: password
|
password: password
|
||||||
}
|
}
|
||||||
this.response = await this.service.post(
|
this.response = await this.service.post(
|
||||||
this.endpoint + '/auth',
|
this.endpoint + 'auth',
|
||||||
body,
|
body,
|
||||||
this.service.defaultToken
|
this.service.defaultToken
|
||||||
)
|
)
|
||||||
|
|
@ -61,16 +60,27 @@ export default class UserService{
|
||||||
|
|
||||||
public async updateUser(user: any, id: number, token: string) {
|
public async updateUser(user: any, id: number, token: string) {
|
||||||
this.response = await this.service.patch(
|
this.response = await this.service.patch(
|
||||||
this.endpoint + '/' + id,
|
this.endpoint + id,
|
||||||
user,
|
user,
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
|
this.serviceUser = {
|
||||||
|
id: this.response.payload.user.id,
|
||||||
|
username: this.response.payload.user.username,
|
||||||
|
email: this.response.payload.user.email,
|
||||||
|
ip: this.response.payload.user.ip,
|
||||||
|
city: this.response.payload.user.city,
|
||||||
|
country: this.response.payload.user.country,
|
||||||
|
token: token
|
||||||
|
}
|
||||||
|
this.dispatch(actions.login(this.serviceUser))
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteUser(id: number, token: string) {
|
public async deleteUser(id: number, token: string) {
|
||||||
this.response = await this.service.delete(
|
this.response = await this.service.delete(
|
||||||
this.endpoint + '/' + id,
|
this.endpoint + id,
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
|
this.deleteAuth(token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue