Changeset View
Changeset View
Standalone View
Standalone View
src/app/_services/registration.service.ts
Show All 23 Lines | recoverPasswordStep1(email: string, username: string, captchaResponse: String): Observable<RecoverTransaction> { | ||||
return this.httpService.POST_NO_TOKEN('/account/recover/', body) | return this.httpService.POST_NO_TOKEN('/account/recover/', body) | ||||
.map((response: Response) => { | .map((response: Response) => { | ||||
// Step 1 successful | // Step 1 successful | ||||
return RecoverTransaction.parse(response); | return RecoverTransaction.parse(response); | ||||
}) | }) | ||||
.catch((error) => { | .catch((error) => { | ||||
return Observable.of( | return Observable.of( | ||||
new RecoverTransactionError( | new RecoverTransactionError( | ||||
error.non_field_errors, | error.error.non_field_errors, | ||||
error.email, | error.error.email, | ||||
error.captcha | error.error.captcha | ||||
) | ) | ||||
); | ); | ||||
}); | }); | ||||
} | } | ||||
recoverPasswordStep2(password: string, token: string, transactionID: string, captchaResponse: String): Observable<Reset> { | recoverPasswordStep2(password: string, token: string, transactionID: string, captchaResponse: String): Observable<Reset> { | ||||
const body = { | const body = { | ||||
'new_password': password, | 'new_password': password, | ||||
'token': token, | 'token': token, | ||||
'transaction': transactionID, | 'transaction': transactionID, | ||||
'captcha': captchaResponse | 'captcha': captchaResponse | ||||
}; | }; | ||||
return this.httpService.POST_NO_TOKEN('/account/recover/reset/', body) | return this.httpService.POST_NO_TOKEN('/account/recover/reset/', body) | ||||
.map((response: Response) => { | .map((response: Response) => { | ||||
// Password reset successful | // Password reset successful | ||||
return Reset.parse(response); | return Reset.parse(response); | ||||
}) | }) | ||||
.catch((error) => { | .catch((error) => { | ||||
return Observable.of( | return Observable.of( | ||||
new ResetError( | new ResetError( | ||||
error.non_field_errors, | error.error.non_field_errors, | ||||
error.new_password, | error.error.new_password, | ||||
error.token, | error.error.token, | ||||
error.transaction, | error.error.transaction, | ||||
error.captcha | error.error.captcha | ||||
) | ) | ||||
); | ); | ||||
}); | }); | ||||
} | } | ||||
recoverUsername(email: string, captchaResponse: String) { | recoverUsername(email: string, captchaResponse: String) { | ||||
const body = { | const body = { | ||||
'email': email, | 'email': email, | ||||
'captcha': captchaResponse | 'captcha': captchaResponse | ||||
}; | }; | ||||
return this.httpService.POST_NO_TOKEN('/account/recover/', body) | return this.httpService.POST_NO_TOKEN('/account/recover/', body) | ||||
.map((response: Response) => { | .map((response: Response) => { | ||||
// Usernames sent successfully | // Usernames sent successfully | ||||
return RecoverTransaction.parse(response); | return RecoverTransaction.parse(response); | ||||
}) | }) | ||||
.catch((error) => { | .catch((error) => { | ||||
return Observable.of( | return Observable.of( | ||||
new RecoverTransactionError( | new RecoverTransactionError( | ||||
error.non_field_errors, | error.error.non_field_errors, | ||||
error.username, | error.error.username, | ||||
error.email, | error.error.email, | ||||
error.captcha | error.error.captcha | ||||
) | ) | ||||
); | ); | ||||
}); | }); | ||||
} | } | ||||
register(username: string, email: string, password: string, captchaResponse: String): Observable<Registration> { | register(username: string, email: string, password: string, captchaResponse: String): Observable<Registration> { | ||||
const body = { | const body = { | ||||
'username': username, | 'username': username, | ||||
Show All 23 Lines |