Commit 503976b525b37a3046e7265cf966d00d912e2fd5
Committed by
Michel Felipe

1 parent
42443554
Exists in
master
and in
7 other branches
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,12 +14,18 @@ export class RegisterComponent { | ||
14 | @Input() account: any; | 14 | @Input() account: any; |
15 | 15 | ||
16 | constructor(private $state: ng.ui.IStateService, public registerService: RegisterService) { | 16 | constructor(private $state: ng.ui.IStateService, public registerService: RegisterService) { |
17 | - this.account = {}; | 17 | + this.account = {}; |
18 | } | 18 | } |
19 | 19 | ||
20 | signup() { | 20 | signup() { |
21 | if (this.account.password === this.account.password_confirmation) { | 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 | } else { | 29 | } else { |
24 | alert("Wrong password confirmation."); | 30 | alert("Wrong password confirmation."); |
25 | } | 31 | } |
src/app/main/main.component.ts
@@ -145,7 +145,6 @@ export class EnvironmentContent { | @@ -145,7 +145,6 @@ export class EnvironmentContent { | ||
145 | url: '/', | 145 | url: '/', |
146 | component: EnvironmentComponent, | 146 | component: EnvironmentComponent, |
147 | name: 'main.environment', | 147 | name: 'main.environment', |
148 | - abstract: true, | ||
149 | views: { | 148 | views: { |
150 | "content": { | 149 | "content": { |
151 | templateUrl: "app/environment/environment.html", | 150 | templateUrl: "app/environment/environment.html", |
src/lib/ng-noosfero-api/http/article.service.spec.ts
@@ -17,7 +17,6 @@ describe("Services", () => { | @@ -17,7 +17,6 @@ describe("Services", () => { | ||
17 | articleService = _ArticleService_; | 17 | articleService = _ArticleService_; |
18 | })); | 18 | })); |
19 | 19 | ||
20 | - | ||
21 | describe("Succesfull requests", () => { | 20 | describe("Succesfull requests", () => { |
22 | 21 | ||
23 | it("should remove article", (done) => { | 22 | it("should remove article", (done) => { |
@@ -92,6 +91,5 @@ describe("Services", () => { | @@ -92,6 +91,5 @@ describe("Services", () => { | ||
92 | }); | 91 | }); |
93 | }); | 92 | }); |
94 | 93 | ||
95 | - | ||
96 | }); | 94 | }); |
97 | }); | 95 | }); |
src/lib/ng-noosfero-api/http/register.service.ts
@@ -9,6 +9,6 @@ export class RegisterService { | @@ -9,6 +9,6 @@ export class RegisterService { | ||
9 | } | 9 | } |
10 | 10 | ||
11 | createAccount(user: noosfero.User): ng.IPromise<noosfero.RestResult<noosfero.User>> { | 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
@@ -80,14 +80,16 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | @@ -80,14 +80,16 @@ export abstract class RestangularService<T extends noosfero.RestModel> { | ||
80 | } | 80 | } |
81 | return { | 81 | return { |
82 | data: (response.data[dataKey] || response.data), | 82 | data: (response.data[dataKey] || response.data), |
83 | - headers: response.headers | 83 | + headers: response.headers, |
84 | + status: response.status | ||
84 | }; | 85 | }; |
85 | }; | 86 | }; |
86 | 87 | ||
87 | protected buildResult(response: restangular.IResponse): noosfero.RestResult<T> { | 88 | protected buildResult(response: restangular.IResponse): noosfero.RestResult<T> { |
88 | return { | 89 | return { |
89 | data: response.data, | 90 | data: response.data, |
90 | - headers: response.headers | 91 | + headers: response.headers, |
92 | + status: response.status | ||
91 | }; | 93 | }; |
92 | }; | 94 | }; |
93 | /** | 95 | /** |
src/lib/ng-noosfero-api/interfaces/rest_result.ts
@@ -3,5 +3,6 @@ namespace noosfero { | @@ -3,5 +3,6 @@ namespace noosfero { | ||
3 | export interface RestResult<T> { | 3 | export interface RestResult<T> { |
4 | data: T; | 4 | data: T; |
5 | headers: Function; | 5 | headers: Function; |
6 | + status: Number; | ||
6 | } | 7 | } |
7 | -} | ||
8 | \ No newline at end of file | 8 | \ No newline at end of file |
9 | +} |