Commit 1a1ffa48a6f9c161093ae1634cd31feaf5e9495e
1 parent
4be49e91
Exists in
updated_signup_page
add redirect to home in case of succeded signup
Signed-off-by: DylanGuedes <djmgguedes@gmail.com> Signed-off-by: ArthurJahn <stutrzbecher@gmail.com>
Showing
6 changed files
with
15 additions
and
9 deletions
Show diff stats
src/app/account/register.component.ts
... | ... | @@ -14,12 +14,18 @@ export class RegisterComponent { |
14 | 14 | @Input() account: any; |
15 | 15 | |
16 | 16 | constructor(private $state: ng.ui.IStateService, public registerService: RegisterService) { |
17 | - this.account = {}; | |
17 | + this.account = {}; | |
18 | 18 | } |
19 | 19 | |
20 | 20 | signup() { |
21 | 21 | if (this.account.password === this.account.password_confirmation) { |
22 | - this.registerService.createAccount(this.account); | |
22 | + this.registerService.createAccount(this.account).then((response) => { | |
23 | + if (response.status === 201) { | |
24 | + this.$state.transitionTo('main.environment'); | |
25 | + } else { | |
26 | + throw new Error('Invalid attributes'); | |
27 | + } | |
28 | + }); | |
23 | 29 | } else { |
24 | 30 | alert("Wrong password confirmation."); |
25 | 31 | } | ... | ... |
src/app/main/main.component.ts
src/lib/ng-noosfero-api/http/article.service.spec.ts
... | ... | @@ -17,7 +17,6 @@ describe("Services", () => { |
17 | 17 | articleService = _ArticleService_; |
18 | 18 | })); |
19 | 19 | |
20 | - | |
21 | 20 | describe("Succesfull requests", () => { |
22 | 21 | |
23 | 22 | it("should remove article", (done) => { |
... | ... | @@ -81,6 +80,5 @@ describe("Services", () => { |
81 | 80 | }); |
82 | 81 | }); |
83 | 82 | |
84 | - | |
85 | 83 | }); |
86 | 84 | }); | ... | ... |
src/lib/ng-noosfero-api/http/register.service.ts
... | ... | @@ -9,6 +9,6 @@ export class RegisterService { |
9 | 9 | } |
10 | 10 | |
11 | 11 | createAccount(user: noosfero.User): ng.IPromise<noosfero.RestResult<noosfero.User>> { |
12 | - return this.Restangular.all('').customPOST(user, "register", user); | |
12 | + return this.Restangular.all("").customPOST(user, "register", user); | |
13 | 13 | } |
14 | 14 | } | ... | ... |
src/lib/ng-noosfero-api/http/restangular_service.ts
... | ... | @@ -58,14 +58,16 @@ export abstract class RestangularService<T extends noosfero.RestModel> { |
58 | 58 | } |
59 | 59 | return { |
60 | 60 | data: response.data[dataKey], |
61 | - headers: response.headers | |
61 | + headers: response.headers, | |
62 | + status: response.status | |
62 | 63 | }; |
63 | 64 | }; |
64 | 65 | |
65 | 66 | protected buildResult(response: restangular.IResponse): noosfero.RestResult<T> { |
66 | 67 | return { |
67 | 68 | data: response.data, |
68 | - headers: response.headers | |
69 | + headers: response.headers, | |
70 | + status: response.status | |
69 | 71 | }; |
70 | 72 | }; |
71 | 73 | /** | ... | ... |